linux内核中的信号机制--信号发送
时间:11-22
来源:互联网
点击:
- GAINwhenlowonmemorywejust
- makesureatleastonesignalgetsdeliveredanddont
- passontheinfostruct.*/
- q=__sigqueue_alloc(t,GFP_ATOMIC,(sig
- ((unsignedlong)info<2||
- info->si_code>=0)));//分配sigqueue结构
- if(q){//如果成功分配到sigqueue结构,就把它添加到队列中,并对其初始化
- list_add_tail(&q->list,&signals->list);
- switch((unsignedlong)info){
- case0:
- q->info.si_signo=sig;
- q->info.si_errno=0;
- q->info.si_code=SI_USER;
- q->info.si_pid=current->pid;
- q->info.si_uid=current->uid;
- break;
- case1:
- q->info.si_signo=sig;
- q->info.si_errno=0;
- q->info.si_code=SI_KERNEL;
- q->info.si_pid=0;
- q->info.si_uid=0;
- break;
- default:
- copy_siginfo(&q->info,info);//拷贝sigqueue结构
- break;
- }
- }else{
- if(sig>=SIGRTMIN&&info&&(unsignedlong)info!=1
- &&info->si_code!=SI_USER)
- /*
- *Queueoverflow,abort.Wemayabortifthesignalwasrt
- *andsentbyuserusingsomethingotherthankill().
- */
- return-EAGAIN;
- if(((unsignedlong)info>1)&&(info->si_code==SI_TIMER))
- /*
- *Setupareturntoindicatethatwedropped
- *thesignal.
- */
- ret=info->si_sys_private;
- }
- out_set:
- sigaddset(&signals->signal,sig);//设置信号位图
- returnret;
- }
[plain]view plaincopyprint?
- /*
- *Tellaprocessthatithasanewactivesignal..
- *
- *NOTE!werelyonthepreviousspin_lockto
- *lockinterruptsforus!Wecanonlybecalledwith
- *"siglock"held,andthelocalinterruptmust
- *havebeendisabledwhenthatgotacquired!
- *
- *Noneedtosetneed_reschedsincesignaleventpassing
- *goesthrough->blocked
- */
- voidsignal_wake_up(structtask_struct*t,intresume)
- {
- unsignedintmask;
- set_tsk_thread_flag(t,TIF_SIGPENDING);//为进程设置TIF_SIGPENDING标志
- /*
- *ForSIGKILL,wewanttowakeitupinthestopped/tracedcase.
- *Wedontcheckt->stateherebecausethereisaracewithit
- *executinganotherprocessorandjustnowenteringstoppedstate.
- *Byusingwake_up_state,weensuretheprocesswillwakeupand
- *handleitsdeathsignal.
- */
- mask=TASK_INTERRUPTIBLE;
- if(resume)
- mask|=TASK_STOPPED|TASK_TRACED;
- if(!wake_up_state(t,mask))
- kick_process(t);
- }
此后当该进程被调度时,在进程返回用户空间前,会调用do_notify_resume()处理该进程的信号。
linux内核信号机制信号发 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)