心得分享

Card image cap

李同學 報告/作業 分享經驗 105.3.23 3/14 OS作業

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

1.
Mutual Exclusion:
If process Pi is executing in its critical section, then no other processes can be executing in their critical sections.
Progress :
Each process can only be blocked at the while if the other process wants to use the critical section. If both of flag[j] and turn==j conditions are true, the other will be allowed to enter the critical section. Upon exiting the critical section, will set flag[j] to false, releasing process i. The shared variable turn assures that only one process at a time can be blocked, and the flag variable allows one process to release the other when exiting their critical section.
Bounded Waiting:
A bound must exist on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.
2.
If both processes try to enter at the same time, turn is set to both i and j at roughly the same time.Only one of these assignments lasts; the other will occur, but will be overwritten immediately.The eventual value of turn decides which of the two processes is allowed to enter its critical section first.
3.
Spinlocks are useful in multiprocessor systems. The advantage of a spinlock is that no context switch is required when a process must wait on a lock.Spinlocks are useful when locks are expected to be held for short times.
4.
(1)No reader will be kept waiting unless a writer has already obtained permission to use the shared database.
(2) Because the shared database can only for one writer using or for one or more reader using. When the shared database is used, wrt will become 0 while the executing is finished, wrt will become 1.
5.
Philosopher i must invoke the operations pickup and putdown in the following sequence:

dp.pickUp(i);

...

eat

...

dp.putDown(i);

This solution ensures that no two neighbors are eating simultaneously, and no deadlocks will occur. However, it is possible for a philosopher to starve to death.

更新日期:2016/3/23 下午 11:26:53