- 论坛徽章:
- 0
|
都说sigsuspend是原子操作,并且ULK3上也有类似的描述
"the sigsuspend() system call does not allow signals to be sent after unblocking and before the schedule() invocation, because other processes cannot grab the CPU during that time interval"
但是从代码上看spin_unlock_irq之后到schedule()之前完全可以被其他CPU抢占。这个原子操作怎么实现呢?
sys_sigsuspend(int history0, int history1, old_sigset_t mask)
{
struct pt_regs * regs = (struct pt_regs *) &history0;
sigset_t saveset;
mask &= _BLOCKABLE;
spin_lock_irq(¤t->sighand->siglock);
saveset = current->blocked;
siginitset(¤t->blocked, mask);
recalc_sigpending();
spin_unlock_irq(¤t->sighand->siglock);
regs->eax = -EINTR;
while (1) {
current->state = TASK_INTERRUPTIBLE;
schedule();
if (do_signal(regs, &saveset))
return -EINTR;
}
}
|
|