incubator-nuttx/sched/signal/sig_unmaskpendingsignal.c

120 lines
3.9 KiB
C
Raw Normal View History

/****************************************************************************
* sched/signal/sig_unmaskpendingsignal.c
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sched.h>
#include <nuttx/signal.h>
#include "sched/sched.h"
#include "signal/signal.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_ This is analogous to similar renaming that was done previously for semaphores. Squashed commit of the following: sched/signal: Fix a few compile warnings introduced by naming changes. sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix. sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces. sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces. sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces. sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces. sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces. sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces. sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-06 03:25:25 +08:00
* Name: nxsig_unmask_pendingsignal
*
* Description:
* Based upon the current setting of the sigprocmask, this function
* unmasks and processes any pending signals. This function should
* be called whenever the sigprocmask is changed.
*
****************************************************************************/
bool nxsig_unmask_pendingsignal(void)
{
FAR struct tcb_s *rtcb = this_task();
2015-10-08 09:59:14 +08:00
sigset_t unmaskedset;
FAR sigpendq_t *pendingsig;
int signo;
2015-10-08 09:59:14 +08:00
/* Prohibit any context switches until we are done with this.
* We may still be performing signal operations from interrupt
* handlers, however, none of the pending signals that we
* are concerned with here should be effected.
*/
2015-10-08 09:59:14 +08:00
sched_lock();
2015-10-08 09:59:14 +08:00
/* Get the set of pending signals that were just unmasked. The
* following operation should be safe because the sigprocmask
* can only be changed on this thread of execution.
*/
unmaskedset = nxsig_pendingset(rtcb);
nxsig_nandset(&unmaskedset, &unmaskedset, &rtcb->sigprocmask);
if (sigisemptyset(&unmaskedset))
{
sched_unlock();
return false;
}
2015-10-08 09:59:14 +08:00
/* Loop while there are unmasked pending signals to be processed. */
do
{
/* Pending signals will be processed from lowest numbered signal
* to highest
*/
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_ This is analogous to similar renaming that was done previously for semaphores. Squashed commit of the following: sched/signal: Fix a few compile warnings introduced by naming changes. sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix. sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces. sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces. sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces. sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces. sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces. sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces. sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-06 03:25:25 +08:00
signo = nxsig_lowest(&unmaskedset);
if (signo != ERROR)
{
/* Remove the signal from the set of unmasked signals. NOTE:
* this implicitly assumes that only one instance for a given
* signal number is pending.
*/
nxsig_delset(&unmaskedset, signo);
/* Remove the pending signal from the list of pending signals */
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_ This is analogous to similar renaming that was done previously for semaphores. Squashed commit of the following: sched/signal: Fix a few compile warnings introduced by naming changes. sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix. sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces. sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces. sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces. sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces. sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces. sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces. sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-06 03:25:25 +08:00
if ((pendingsig = nxsig_remove_pendingsignal(rtcb, signo)) != NULL)
{
/* If there is one, then process it like a normal signal.
* Since the signal was pending, then unblocked on this
* thread, we can skip the normal group signal dispatching
* rules; there can be no other recipient for the signal
* other than this thread.
*/
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_ This is analogous to similar renaming that was done previously for semaphores. Squashed commit of the following: sched/signal: Fix a few compile warnings introduced by naming changes. sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix. sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces. sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces. sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces. sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces. sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces. sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces. sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-06 03:25:25 +08:00
nxsig_tcbdispatch(rtcb, &pendingsig->info);
/* Then remove it from the pending signal list */
This change renames all internal, private NuttX signal-related functions to use the prefix nxsig_ so that they cannot be confused with application interfaces that begin, primarily, with sig_ This is analogous to similar renaming that was done previously for semaphores. Squashed commit of the following: sched/signal: Fix a few compile warnings introduced by naming changes. sched/signal: Rename all private, internal signl functions to use the nxsig_ prefix. sched/signal: Rename sig_removependingsignal, sig_unmaskpendingsignal, and sig_mqnotempty to nxsig_remove_pendingsignal, nxsig_unmask_pendingsignal, and nxsig_mqnotempty to make it clear that these are OS internal interfaces. sched/signal: Rename sig_findaction and sig_lowest to nxsig_find_action and nxsig_lowest to make it clear that these are OS internal interfaces. sched/signal: Rename sig_allocatepingsigaction and sig_deliver to nxsig_alloc_pendingsigaction and nxsig_deliver to make it clear that these are OS internal interfaces. sched/signal: Rename sig_cleanup, sig_release, sig_releasependingaction, and sig_releasependingsignal to nxsig_cleanup, nxsig_release, nxsig_release_pendingaction, and nxsig_release_pendingsignal to make it clear that these are OS internal interfaces. sched/signal: Rename sig_tcbdispatch and sig_dispatch to nxsig_tcbdispatch and nxsig_dispatch to make it clear that these are OS internal interfaces. sched/signal: Rename sig_releaseaction and sig_pendingset to nxsig_release_action and nxsig_pendingset to make it clear that these are OS internal interfaces. sched/signal: Rename sig_initialize and sig_allocateactionblock to nxsig_initialize and nxsig_alloc_actionblock to make it clear that these are OS internal interfaces.
2017-10-06 03:25:25 +08:00
nxsig_release_pendingsignal(pendingsig);
}
}
}
while (!sigisemptyset(&unmaskedset));
sched_unlock();
return true;
}