心得分享

Card image cap

郭同學 報告/作業 分享經驗 3/23 3/15 OS作業

3/23 3/15 OS作業
名稱 3/15 OS作業
日期 3/23
課程名稱 作業系統
指導教師 劉艾華

1.
Mutual exclusion: P0 and P1 can never be in the critical section at the same time: If P0 is in its critical section, then flag[0] is true. In addition, either flag[1] is false (meaning P1 has left its critical section), or turn is 0 (meaning P1 is just now trying to enter the critical section, but graciously waiting), or P1 is at label P1_gate (trying to enter its critical section, after setting flag[1] to true but before setting turn to 0 and busy waiting). So if both processes are in their critical sections then we conclude that the state must satisfy flag[0] and flag[1] and turn = 0 and turn = 1. No state can satisfy both turn = 0 and turn = 1, so there can be no state where both processes are in their critical sections.

Progress: Progress is defined as the following: if no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in making the decision as to which process will enter its critical section next. This selection cannot be postponed indefinitely.A process cannot immediately re-enter the critical section if the other process has set its flag to say that it would like to enter its critical section.

Bounded waiting: Bounded waiting means that the number of times a process is bypassed by another process after it has indicated its desire to enter the critical section is bounded by a function of the number of processes in the system.In Peterson's algorithm, a process will never wait longer than one turn for entrance to the critical section: After giving priority to the other process, this process will run to completion and set its flag to 1, thereby never allowing the other process to enter the critical section.

2.
The final value of turn will decide which process enters its critical section first.

3.
(1)The execution flow is usually easier to comprehend and thus less error prone.
(2)Timing can be determined more accurately in some cases

4.
(1)No reader will be kept waiting unless a writer has already obtained permission to use the shared database.
(2)Once a writer is ready, that writer performs its write as soon as possible. If a writer is waiting to access the object, no new readers may start reading.

更新日期:2016/3/23 下午 10:20:58