⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pthread.h

📁 用于移植在pthread环境中开发的应用程序到没有pthread支持的环境
💻 H
字号:
/**************************************************************************
 *	FILE NAME:
 *		pthread.h
 *
 *	DESCRIPTION:
 *		This file is the header file of pthread module.
 *
 *	NOTES:
 *
 *	EDIT HISTORY
 *	$Log: pthread.h,v $
 *	Revision 1.3  2003/08/27 04:53:27  rexyan
 *	In pthread_get_num, added thread_seq_num = 1;
 *	In pthread_con_timedwait, added send tid to msgQ;
 *	in pthread_create, added a input parameter arg_len
 *	
 *	Revision 1.2  2003/08/26 04:04:17  rexyan
 *	Added EDIT HISTORY
 *	
 *
 **************************************************************************
*/
#ifndef _PTHREAD_H_
#define _PTHREAD_H_

#include <msgQLib.h>
#include <semLib.h>
#include <time.h>

#define PTHR_MAX_THREAD_NUM 100
#define PTHR_MAX_WAITERS    10
#define PTHR_MAX_ARG_LEN    1000

#define PTHR_FAILURE    0
#define PTHR_SUCCESS    1

 /* typedes for simulated  pthread. we simulate the pthread with vxWorks task */

typedef int  pthread_t;

/* 
 * attribute of the phtread, actually the priority and stack size of vxWorks 
 * task 
 */
 
typedef struct pthread_attr_s
{
	unsigned char	priority;	/* proority of the thread to be spawned */
	int	stack_size;	/* stack size of the spawned thread */
} pthread_attr_t;

/* we implemented a conditional variable by using a message queue */
typedef struct pthread_cond_s 
{
    unsigned char  defunct; 
    MSG_Q_ID        waite_msg_q; 
} pthread_cond_t;                           

/* conditional vaiable attribute, we ignore it */
typedef void		pthread_cond_attr_t;    

typedef SEM_ID		pthread_mutex_t;         /* mutex semaphore */

int ptherad_module_init( void );
int pthread_create(pthread_t *thread_id, const pthread_attr_t *attr,
                   void *(*start_routine)(void *), void *arg, int arg_len);

int pthread_cond_init( pthread_cond_t *cond , const pthread_cond_attr_t * attr );
int pthread_cond_destroy( pthread_cond_t * cond );
int pthread_cond_wait( pthread_cond_t * cond , pthread_mutex_t * mutex );
int pthread_cond_timedwait( pthread_cond_t * cond , pthread_mutex_t * mutex, 
                       const struct timespec * abstime );
int pthread_cond_signal( pthread_cond_t * cond );
int pthread_mutex_init( pthread_mutex_t *mutex, char *dummy );
int pthread_mutex_lock( pthread_mutex_t *mutex );
int pthread_mutex_unlock( pthread_mutex_t *mutex );

int pthread_delay_np(const struct timespec *t);

#endif /* _P_THREAD_H_ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -