I am trying to implement sigprocmask in XV6. In that if the first parameter i.e how=SIG_UNBLOCK then as per my understanding the process mask must be removed. For that I was instructed to do
curproc->sigmask &= ~(*set);
But I am unable to understand this calculation. Can someone please explain? Thanks!
In your question, you don't precise the type of
sigmaskorset, I will assume that they are 32 bits integer (int) and pointer on 32 bits integer (int *).The line
can be rewritten:
So for instance, if you want to set the signal whose code is 3 (SIGINT in linux), you must first raise the third bit of an integer:
Then call the function,
setwill be equal to&sig,After line
temp = ~temp;, temp will have all bits set but thirdAfter line
mask = mask & temp;all bits inmaskwill be kept but third that will be clear.