Back to index

glibc  2.9
preempt-sig.c
Go to the documentation of this file.
00001 /* Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #include <hurd/sigpreempt.h>
00020 #include <hurd/signal.h>
00021 #include <assert.h>
00022 
00023 void
00024 hurd_preempt_signals (struct hurd_signal_preemptor *preemptor)
00025 {
00026   __mutex_lock (&_hurd_siglock);
00027   preemptor->next = _hurdsig_preemptors;
00028   _hurdsig_preemptors = preemptor;
00029   _hurdsig_preempted_set |= preemptor->signals;
00030   __mutex_unlock (&_hurd_siglock);
00031 }
00032 
00033 void
00034 hurd_unpreempt_signals (struct hurd_signal_preemptor *preemptor)
00035 {
00036   struct hurd_signal_preemptor **p;
00037   sigset_t preempted = 0;
00038 
00039   __mutex_lock (&_hurd_siglock);
00040 
00041   p = &_hurdsig_preemptors;
00042   while (*p)
00043     if (*p == preemptor)
00044       {
00045        /* Found it; take it off the chain.  */
00046        *p = (*p)->next;
00047        if ((preemptor->signals & preempted) != preemptor->signals)
00048          {
00049            /* This might have been the only preemptor for some
00050               of those signals, so we must collect the full mask
00051               from the others.  */
00052            struct hurd_signal_preemptor *pp;
00053            for (pp = *p; pp; pp = pp->next)
00054              preempted |= pp->signals;
00055            _hurdsig_preempted_set = preempted;
00056          }
00057        __mutex_unlock (&_hurd_siglock);
00058        return;
00059       }
00060     else
00061       {
00062        preempted |= (*p)->signals;
00063        p = &(*p)->next;
00064       }
00065 
00066   __mutex_unlock (&_hurd_siglock); /* Avoid deadlock during death rattle.  */
00067   assert (! "removing absent preemptor");
00068 }