-1
这是我在操作系统考试中遇到的一个问题。我无法弄清楚它的正确答案。可有人help.Given采用锁相同步,其中许多线程试图访问一个全局计数器g的代码同步(操作系统)
if(lock==1)
wait(); //sleep this thread until some other thread wakes up this thread
else
lock=1; //enter in protected area
//access global counter g//
lock=0;
//wake up some other thread which is waiting for the lock to be released
什么是上面同步的问题?选择下面给出的选项中的任何一个
- 同步很好,并且可以正常运行。
- 只能在单处理器系统上运行,而不能在多处理器系统上运行。
- 不会在任何系统上运行
- 不能说。需要更多数据
'lock = 1'是什么意思?锁的设置和测试应该是原子的吗?锁定是否与等待队列交互? –
当有人访问变量时,我认为lock = 1。当有人不是时,它是0 – Akshit