码迷,mamicode.com
首页 > 其他好文 > 详细

Processes and Threads

时间:2015-08-18 21:03:09      阅读:181      评论:0      收藏:0      [点我收藏+]

标签:

Part 1: Processes

Process: an abstraction of running program.

A CPU can really only run one process at a time, if there are two cores each one of them can run only one process at a time.

 

Process Creation

Operating systems need some way to create processes. There are four events that cause processes to be created:

  1. System initialization
  2. Execution of a process creation system call by a running process
  3. A user request to create a new process
  4. Initiation of a batch job

 

Daemons: processes that stay in the background to handle some activity such as e-mail, Web pages, news, printing, and so on.

 

Note: in UNIX, the ps program can be used to list the running processes. In windows, task manager.

Note: in UNIX, only one system call to create a new process: fork. In windows, CreateProcess

 

Process Termination, usually due to one of the following conditions:

  1. Normal exit (voluntary)
  2. Error exit (voluntary)
  3. Fatal error (involuntary)
  4. Killed by another process (involuntary)

Note: exit()  in UNIX and ExitProcess() in Windows

 

Process States

  • Running (actually using the CPU at that instant)
  • Ready (runnable; temporaily stopped to let another process run)
  • Blocked (unable to run until some external event happens)

技术分享

 

 

Part 2: THREADS

 

Processes and Threads

标签:

原文地址:http://www.cnblogs.com/elewei/p/4740512.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!