线程(Thread)
* 线程(Thread) 举例:从fork()看线程 main() { int pid = 0; printf(“the parent is going to fork\n”); if ((pid = fork()) != 0) printf(“I am the father of %d\n”, pid); else printf(“I am the child\n”); } Single-threaded vs Multi-threaded(单线程 vs 多线程) 线程间共享内存空间 线程相对于进程的优势 Responsiveness (e.g. Web应用前端) Resource Sharing (e.g. shared variable) Economy (e.g. save memory) Utilization of MP Architectures 用户级线程(User Threads) 线程管理(创建、资源申请、调度、通信等)由user-level threads library“一手包办”,不靠OS内核 举例,Three primary thread libraries: Java threads POSIX pthreads Win32 threads 内核级(Kernel Threads) 线程管理由操作
原创力文档

文档评论(0)