100 lines
3.2 KiB
C
100 lines
3.2 KiB
C
/****************************************************************************
|
|
* libs/libc/wqueue/work_signal.c
|
|
*
|
|
* 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 <signal.h>
|
|
#include <errno.h>
|
|
|
|
#include <nuttx/wqueue.h>
|
|
|
|
#include "wqueue/wqueue.h"
|
|
|
|
#if defined(CONFIG_LIB_USRWORK) && !defined(__KERNEL__)
|
|
|
|
/****************************************************************************
|
|
* Pre-processor Definitions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Private Type Declarations
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Public Data
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Private Data
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Private Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Public Functions
|
|
****************************************************************************/
|
|
|
|
/****************************************************************************
|
|
* Name: work_signal
|
|
*
|
|
* Description:
|
|
* Signal the worker thread to process the work queue now. This function
|
|
* is used internally by the work logic but could also be used by the
|
|
* user to force an immediate re-assessment of pending work.
|
|
*
|
|
* Input Parameters:
|
|
* qid - The work queue ID
|
|
*
|
|
* Returned Value:
|
|
* Zero on success, a negated errno on failure
|
|
*
|
|
****************************************************************************/
|
|
|
|
int work_signal(int qid)
|
|
{
|
|
int ret;
|
|
|
|
if (qid == USRWORK)
|
|
{
|
|
/* Signal the worker thread */
|
|
|
|
ret = kill(g_usrwork.pid, SIGWORK);
|
|
if (ret < 0)
|
|
{
|
|
int errcode = get_errno();
|
|
ret = -errcode;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ret = -EINVAL;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
#endif /* CONFIG_LIB_USRWORK && !__KERNEL__ */
|