进程同步02--临界区问题(Critical Section Problem)

来源:互联网 发布:知乎科目三新规 编辑:程序博客网 时间:2024/05/16 23:55

临界区问题:
假设现有n个进程(P1, P2,…,Pn), 每个进程都如图所示, 拥有一个可以修改共享变量(变量, 文件, 数据库表等)的临界区(critical section), 要求任何一个进程在临界区执行时, 其他都不能执行.
这里写图片描述

正式定义:

  1. Mutual exclusion(互斥): When a thread is executing in its critical section, no other threads can be executing in their critical sections.
  2. Progress(前进): If no thread is executing in its critical section, and if there are some threads that wish to enter their critical sections, then one of these threads will get into the critical section.
  3. Bounded waiting(有限次等待): After a thread makes a request to enter its critical section, there is a bound on the number of times that other threads are allowed to enter their critical sections, before the request is granted.
阅读全文
0 0
原创粉丝点击