`
deepfuture
  • 浏览: 4425805 次
  • 性别: Icon_minigender_1
  • 来自: 湛江
博客专栏
073ec2a9-85b7-3ebf-a3bb-c6361e6c6f64
SQLite源码剖析
浏览量:80284
1591c4b8-62f1-3d3e-9551-25c77465da96
WIN32汇编语言学习应用...
浏览量:70705
F5390db6-59dd-338f-ba18-4e93943ff06a
神奇的perl
浏览量:103897
Dac44363-8a80-3836-99aa-f7b7780fa6e2
lucene等搜索引擎解析...
浏览量:287187
Ec49a563-4109-3c69-9c83-8f6d068ba113
深入lucene3.5源码...
浏览量:15109
9b99bfc2-19c2-3346-9100-7f8879c731ce
VB.NET并行与分布式编...
浏览量:68203
B1db2af3-06b3-35bb-ac08-59ff2d1324b4
silverlight 5...
浏览量:32461
4a56b548-ab3d-35af-a984-e0781d142c23
算法下午茶系列
浏览量:46218
社区版块
存档分类
最新评论

pthread所有结构类型

阅读更多

/* Copyright (C) 2002,2003,2004,2005,2006,2007 Free Software Foundation, Inc.

   This file is part of the GNU C Library.

   Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.

 

   The GNU C Library is free software; you can redistribute it and/or

   modify it under the terms of the GNU Lesser General Public

   License as published by the Free Software Foundation; either

   version 2.1 of the License, or (at your option) any later version.

 

   The GNU C Library is distributed in the hope that it will be useful,

   but WITHOUT ANY WARRANTY; without even the implied warranty of

   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU

   Lesser General Public License for more details.

 

   You should have received a copy of the GNU Lesser General Public

   License along with the GNU C Library; if not, write to the Free

   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA

   02111-1307 USA.  */

 

#ifndef _BITS_PTHREADTYPES_H

#define _BITS_PTHREADTYPES_H 1

 

#include <bits/wordsize.h>

 

#if __WORDSIZE == 64

# define __SIZEOF_PTHREAD_ATTR_T 56

# define __SIZEOF_PTHREAD_MUTEX_T 40

# define __SIZEOF_PTHREAD_MUTEXATTR_T 4

# define __SIZEOF_PTHREAD_COND_T 48

# define __SIZEOF_PTHREAD_CONDATTR_T 4

# define __SIZEOF_PTHREAD_RWLOCK_T 56

# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8

# define __SIZEOF_PTHREAD_BARRIER_T 32

# define __SIZEOF_PTHREAD_BARRIERATTR_T 4

#else

# define __SIZEOF_PTHREAD_ATTR_T 36

# define __SIZEOF_PTHREAD_MUTEX_T 24

# define __SIZEOF_PTHREAD_MUTEXATTR_T 4

# define __SIZEOF_PTHREAD_COND_T 48

# define __SIZEOF_PTHREAD_CONDATTR_T 4

# define __SIZEOF_PTHREAD_RWLOCK_T 32

# define __SIZEOF_PTHREAD_RWLOCKATTR_T 8

# define __SIZEOF_PTHREAD_BARRIER_T 20

# define __SIZEOF_PTHREAD_BARRIERATTR_T 4

#endif

 

 

/* Thread identifiers.  The structure of the attribute type is not

   exposed on purpose.  */

typedef unsigned long int pthread_t;

 

 

typedef union

{

  char __size[__SIZEOF_PTHREAD_ATTR_T];

  long int __align;

} pthread_attr_t;

 

 

#if __WORDSIZE == 64

typedef struct __pthread_internal_list

{

  struct __pthread_internal_list *__prev;

  struct __pthread_internal_list *__next;

} __pthread_list_t;

#else

typedef struct __pthread_internal_slist

{

  struct __pthread_internal_slist *__next;

} __pthread_slist_t;

#endif

 

 

/* Data structures for mutex handling.  The structure of the attribute

   type is not exposed on purpose.  */

typedef union

{

  struct __pthread_mutex_s

  {

    int __lock;

    unsigned int __count;

    int __owner;

#if __WORDSIZE == 64

    unsigned int __nusers;

#endif

    /* KIND must stay at this position in the structure to maintain

       binary compatibility.  */

    int __kind;

#if __WORDSIZE == 64

    int __spins;

    __pthread_list_t __list;

# define __PTHREAD_MUTEX_HAVE_PREV 1

#else

    unsigned int __nusers;

    __extension__ union

    {

      int __spins;

      __pthread_slist_t __list;

    };

#endif

  } __data;

  char __size[__SIZEOF_PTHREAD_MUTEX_T];

  long int __align;

} pthread_mutex_t;

 

typedef union

{

  char __size[__SIZEOF_PTHREAD_MUTEXATTR_T];

  int __align;

} pthread_mutexattr_t;

 

 

/* Data structure for conditional variable handling.  The structure of

   the attribute type is not exposed on purpose.  */

typedef union

{

  struct

  {

    int __lock;

    unsigned int __futex;

    __extension__ unsigned long long int __total_seq;

    __extension__ unsigned long long int __wakeup_seq;

    __extension__ unsigned long long int __woken_seq;

    void *__mutex;

    unsigned int __nwaiters;

    unsigned int __broadcast_seq;

  } __data;

  char __size[__SIZEOF_PTHREAD_COND_T];

  __extension__ long long int __align;

} pthread_cond_t;

 

typedef union

{

  char __size[__SIZEOF_PTHREAD_CONDATTR_T];

  int __align;

} pthread_condattr_t;

 

 

/* Keys for thread-specific data */

typedef unsigned int pthread_key_t;

 

 

/* Once-only execution */

typedef int pthread_once_t;

 

 

#if defined __USE_UNIX98 || defined __USE_XOPEN2K

/* Data structure for read-write lock variable handling.  The

   structure of the attribute type is not exposed on purpose.  */

typedef union

{

# if __WORDSIZE == 64

  struct

  {

    int __lock;

    unsigned int __nr_readers;

    unsigned int __readers_wakeup;

    unsigned int __writer_wakeup;

    unsigned int __nr_readers_queued;

    unsigned int __nr_writers_queued;

    int __writer;

    int __shared;

    unsigned long int __pad1;

    unsigned long int __pad2;

    /* FLAGS must stay at this position in the structure to maintain

       binary compatibility.  */

    unsigned int __flags;

  } __data;

# else

  struct

  {

    int __lock;

    unsigned int __nr_readers;

    unsigned int __readers_wakeup;

    unsigned int __writer_wakeup;

    unsigned int __nr_readers_queued;

    unsigned int __nr_writers_queued;

    /* FLAGS must stay at this position in the structure to maintain

       binary compatibility.  */

    unsigned char __flags;

    unsigned char __shared;

    unsigned char __pad1;

    unsigned char __pad2;

    int __writer;

  } __data;

# endif

  char __size[__SIZEOF_PTHREAD_RWLOCK_T];

  long int __align;

} pthread_rwlock_t;

 

typedef union

{

  char __size[__SIZEOF_PTHREAD_RWLOCKATTR_T];

  long int __align;

} pthread_rwlockattr_t;

#endif

 

 

#ifdef __USE_XOPEN2K

/* POSIX spinlock data type.  */

typedef volatile int pthread_spinlock_t;

 

 

/* POSIX barriers data type.  The structure of the type is

   deliberately not exposed.  */

typedef union

{

  char __size[__SIZEOF_PTHREAD_BARRIER_T];

  long int __align;

} pthread_barrier_t;

 

typedef union

{

  char __size[__SIZEOF_PTHREAD_BARRIERATTR_T];

  int __align;

} pthread_barrierattr_t;

#endif

 

 

#if __WORDSIZE == 32

/* Extra attributes for the cleanup functions.  */

# define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))

#endif

 

#endif /* bits/pthreadtypes.h */

分享到:
评论

相关推荐

    linux 多线程编程 pthread

    - 使用`pthread_mutexattr_getprotocol`获取互斥锁类型的属性。 **设置互斥锁属性的协议** - 使用`pthread_mutexattr_setprioceiling`设置互斥锁属性的协议。 **获取互斥锁属性的协议** - 使用`pthread_...

    Pthread-Primer.rar_pthread_unix primer

    1. 互斥锁(Mutex):`pthread_mutex_t`类型的数据结构,用于保护临界区,防止多个线程同时访问共享资源。 2. 条件变量(Condition Variable):`pthread_cond_t`,配合互斥锁实现线程间的同步等待和唤醒。 3. 读写...

    Pthread互斥问题

    在Pthreads中,我们使用`pthread_mutex_t`类型来表示互斥锁,并通过`pthread_mutex_init()`初始化,`pthread_mutex_lock()`获取锁,`pthread_mutex_unlock()`释放锁。 以下是一个简单的示例,展示了如何在Pthreads...

    pthread多线程编程

    这个函数接受一个`pthread_t`类型的变量作为线程标识符,一个`pthread_attr_t`结构体指针(可选地指定线程属性,如栈大小和调度策略),一个回调函数(线程入口点),以及一个传递给该函数的参数。 ```c pthread_...

    天津大学并行计算Pthread实验代码(C++)

    在这个过程中,开发者需要理解并掌握pthread_create()函数用于创建新线程,pthread_join()函数等待线程结束,以及pthread_mutex_t类型用于线程间的同步,防止数据竞争。 接下来是"pbs脚本"。PBS(Portable Batch ...

    6_pthread.rar

    在Linux中,pthread库提供了`pthread_mutex_t`类型来表示互斥锁,使用`pthread_mutex_init()`初始化,`pthread_mutex_lock()`获取锁,`pthread_mutex_unlock()`释放锁。通过这些函数,可以避免竞态条件,保证线程...

    由浅入深Linux下pthread线程库介绍

    1. **线程标识符类型**:`pthread_t` 是线程的标识符类型,它定义在头文件 `/usr/include/bits/pthreadtypes.h` 中,其定义为 `typedef unsigned long int pthread_t;`。 2. **线程创建**:`pthread_create` 函数...

    pthread_fab

    它需要一个线程标识符(pthread_t类型)来存储新线程的ID,一个函数指针(线程执行的入口点),以及一个指向用户定义的数据结构的指针,该数据结构可以在线程函数中使用。 3. **线程函数**:在`pthread_fab`中,...

    QT中多线程

    至于参数传递,`pthread_create`允许通过`arg`参数向线程函数传递任意类型的数据。你可以封装成结构体或指针,以传递复杂的数据结构。例如: ```cpp struct ThreadArgs { int value1; QString value2; }; void* ...

    Windows下使用Dev-C++开发基于pthread.h的多线程程序实例

    在main函数中,首先创建了一个pthread_t类型的线程标识符tid。通过pthread_create函数创建一个新线程,该函数的参数依次是线程标识符、线程属性(此处为NULL,即使用默认属性)、指向线程函数的指针以及传递给线程...

    POSIX线程编程指南.pdf

    - `thread`:指向一个pthread_t类型的指针,用于存储新创建的线程ID。 - `attr`:指向一个pthread_attr_t类型的指针,用于指定新线程的属性。如果为NULL,则使用默认属性。 - `start_routine`:指向新线程执行的...

    Linux系统编程之线程同步

    pthread_mutex_t 类型,其本质是一个结构体。为简化理解,应用时可忽略其实现细节,简单当成整数看待。 pthread_mutex_t mutex; 变量mutex只有两种取值1、0。 pthread_mutex_init函数 初始化一个互斥锁(互斥量) ---&gt;...

    linux 多进程多线程编程

    使用 pthread_setcanceltype 函数可以设置取消类型,原型为: ```c int pthread_setcanceltype(int type, int *oldtype); ``` 其中,type 是取消类型,oldtype 是原来的取消类型。 14. 初始化属性 使用 pthread_...

    pthreads.zip

    头文件通常以`pthread.h`为名,它是使用pthread函数的入口,定义了线程创建、同步、通信等功能的函数原型和数据结构。库文件则包含实现了这些函数的代码,通常在编译链接时需要引用。 配置文件可能是指导如何在特定...

    pthreads-w32-2-9-1-release.zip

    `pthread`库是POSIX标准的一部分,提供了创建、同步和管理线程的一系列函数,如`pthread_create`用于创建线程,`pthread_join`用于等待线程结束,以及`pthread_mutex_t`和`pthread_rwlock_t`等用于线程同步的类型。...

    linux多线程编程指南

    - 使用`pthread_setcanceltype()`函数设置取消类型。 - 示例代码: ```c int type = PTHREAD_CANCEL_ASYNCHRONOUS; pthread_setcanceltype(type, NULL); ``` - **创建取消点:** - 可以在代码中插入取消点,...

    linux环境下多线程编程

    - **pthread_key_delete()**: 删除一个线程特定数据键,一旦删除,所有线程中与此键相关的数据也将被释放。 #### 三、设置线程特定数据 **3.1 获取线程特定数据** - **pthread_getspecific()**: 从指定的线程特定...

    sun多线程编程 linux下多线程

    - 使用`pthread_setcanceltype`函数设置线程的取消类型,例如延时取消或立即取消。 **创建取消点** - 在可能的取消点处调用`pthread_testcancel`函数,检查线程是否已被取消。 **将处理程序推送到栈上** - 使用`...

    sun多线程编程

    - **设置互斥锁类型的属性**: 使用`pthread_mutexattr_settype`函数设置互斥锁类型。 - **获取互斥锁的类型属性**: 使用`pthread_mutexattr_gettype`函数获取互斥锁类型。 - **设置互斥锁属性的协议**: 使用`pthread...

Global site tag (gtag.js) - Google Analytics