pthread

本文介绍了进程和线程的基本管理方法,包括fork()函数创建子进程、waitpid()等待子进程结束、pthread_create()创建线程等关键API,并讨论了同步机制如互斥锁、条件变量及信号量的应用。

note:

Process Mode:

pid_t pid = fork()

if ( pid == 0)

{  // child process to do }

else

{ // parent process to do

  // waitpid( pid, & status, WNOHANG)

}

Pthread API

pthread_t thread;

int pthread_create( pthread_t * thread, const pthread_att_t * att,

                                void *(*start)(void *), void * arg)

pthread_t  pthread_self()

int sched_yield()

int pthread_exit( void * value_ptr);

int pthread_detach( pthread_t pthread)

int pthread_jion( pthread_t thread, void **value_ptr)

2. synchronous

 mutax

 condition variable ( when the mutux condition does not meet, it will releas the mutux)

 semphore

转载于:https://www.cnblogs.com/zhyg6516/archive/2011/02/18/1957459.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值