Chinaunix首页 | 论坛 | 博客
  • 博客访问: 314452
  • 博文数量: 72
  • 博客积分: 2580
  • 博客等级: 少校
  • 技术积分: 675
  • 用 户 组: 普通用户
  • 注册时间: 2009-11-07 17:36
文章分类

全部博文(72)

文章存档

2012年(7)

2011年(17)

2010年(46)

2009年(2)

分类: LINUX

2010-08-05 12:15:49

===================================
Thread life
1. thread state
 contain four statuses and each status may contain some substate.
 The basic-state: 1. Ready 2. Running 3. Blocked 4. Terminated
 Note: the state will decise the the scheudle of the thread.
 Terminated stated:
 when detached, thread is immediately recycled. But when non-detached, the terminted state will be remained untill it joined or detached.
 
 
2. creation..
 Note: In system of supporting thread, no code could run without a thread. The first thread is created by system, and additional thread should be created by explict calls.
 And the create function has no synchronization machincism. So the thread maybe run before the function returning.
3. Starting..
 In gernal, the start function of the process ( main thread ) is called from outside your programm, it usually link a file called crt0.o, then the main call will be called. And other thread will start at the thread function address.
 And another thing shouled be noted, is that thread terminate. If the main thread is terminated using return, the other thread will be terminated immediatedly. If want the other thread still run after the main thread exit, could use the pthread_exit to terminate the main thread.
4. Running and block 
  
5. termination
阅读(847) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~