2012-09-04 02:54:09 +02:00
|
|
|
/****************************************************************************
|
2018-05-29 21:21:26 +02:00
|
|
|
* libs/libc/wqueue/work_signal.c
|
2012-09-04 02:54:09 +02:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* 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
|
2012-09-04 02:54:09 +02:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2012-09-04 02:54:09 +02:00
|
|
|
*
|
2021-03-02 15:54:21 +01:00
|
|
|
* 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.
|
2012-09-04 02:54:09 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <signal.h>
|
2014-10-10 22:52:04 +02:00
|
|
|
#include <errno.h>
|
2012-09-04 02:54:09 +02:00
|
|
|
|
|
|
|
#include <nuttx/wqueue.h>
|
|
|
|
|
2014-10-10 16:35:58 +02:00
|
|
|
#include "wqueue/wqueue.h"
|
|
|
|
|
2014-10-11 23:59:40 +02:00
|
|
|
#if defined(CONFIG_LIB_USRWORK) && !defined(__KERNEL__)
|
2012-09-04 02:54:09 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Type Declarations
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2015-10-03 00:30:35 +02:00
|
|
|
* Public Data
|
2012-09-04 02:54:09 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
2016-02-22 01:08:58 +01:00
|
|
|
* Private Data
|
2012-09-04 02:54:09 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
2021-03-02 14:33:27 +01:00
|
|
|
|
2012-09-04 02:54:09 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* 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.
|
|
|
|
*
|
2018-02-01 17:00:02 +01:00
|
|
|
* Input Parameters:
|
2012-09-04 02:54:09 +02:00
|
|
|
* qid - The work queue ID
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero on success, a negated errno on failure
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int work_signal(int qid)
|
|
|
|
{
|
2014-10-10 16:35:58 +02:00
|
|
|
int ret;
|
|
|
|
|
|
|
|
if (qid == USRWORK)
|
|
|
|
{
|
|
|
|
/* Signal the worker thread */
|
|
|
|
|
2014-10-11 00:24:50 +02:00
|
|
|
ret = kill(g_usrwork.pid, SIGWORK);
|
2014-10-10 16:35:58 +02:00
|
|
|
if (ret < 0)
|
|
|
|
{
|
2018-01-31 00:57:36 +01:00
|
|
|
int errcode = get_errno();
|
2014-10-10 22:52:04 +02:00
|
|
|
ret = -errcode;
|
2014-10-10 16:35:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-10-10 22:52:04 +02:00
|
|
|
ret = -EINVAL;
|
2014-10-10 16:35:58 +02:00
|
|
|
}
|
2014-10-10 22:52:04 +02:00
|
|
|
|
|
|
|
return ret;
|
2012-09-04 02:54:09 +02:00
|
|
|
}
|
|
|
|
|
2014-10-11 23:59:40 +02:00
|
|
|
#endif /* CONFIG_LIB_USRWORK && !__KERNEL__ */
|