mm/iob: IOB free notifier should accept the work queue ID as a paramter. The notification may need to run on either the high- or low- priority work queue. sched/work: Change the default priority of the low-priority work queue to 100.

This commit is contained in:
Gregory Nutt 2018-09-11 08:49:39 -06:00
parent 91aa26774b
commit 11a635dcb3
9 changed files with 37 additions and 36 deletions

View File

@ -213,10 +213,11 @@ FAR struct iob_s *iob_free(FAR struct iob_s *iob);
* *
* Description: * Description:
* Set up to perform a callback to the worker function when an IOB is * Set up to perform a callback to the worker function when an IOB is
* available. The worker function will execute on the high priority * available. The worker function will execute on the selected priority
* worker thread. * worker thread.
* *
* Input Parameters: * Input Parameters:
* qid - Selects work queue. Must be HPWORK or LPWORK.
* worker - The worker function to execute on the high priority work queue * worker - The worker function to execute on the high priority work queue
* when the event occurs. * when the event occurs.
* arg - A user-defined argument that will be available to the worker * arg - A user-defined argument that will be available to the worker
@ -235,7 +236,7 @@ FAR struct iob_s *iob_free(FAR struct iob_s *iob);
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_IOB_NOTIFIER #ifdef CONFIG_IOB_NOTIFIER
int iob_notifier_setup(worker_t worker, FAR void *arg); int iob_notifier_setup(int qid, worker_t worker, FAR void *arg);
#endif #endif
/**************************************************************************** /****************************************************************************

View File

@ -296,7 +296,7 @@ enum work_evtype_e
struct work_notifier_s struct work_notifier_s
{ {
uint8_t evtype; /* See enum work_evtype_e */ uint8_t evtype; /* See enum work_evtype_e */
uint8_t wqueue; /* The work queue to use: HPWORK or LPWORK */ uint8_t qid; /* The work queue to use: HPWORK or LPWORK */
FAR void *qualifier; /* Event qualifier value */ FAR void *qualifier; /* Event qualifier value */
FAR void *arg; /* User-defined worker function argument */ FAR void *arg; /* User-defined worker function argument */
worker_t worker; /* The worker function to schedule */ worker_t worker; /* The worker function to schedule */

View File

@ -58,10 +58,11 @@
* *
* Description: * Description:
* Set up to perform a callback to the worker function when an IOB is * Set up to perform a callback to the worker function when an IOB is
* available. The worker function will execute on the high priority * available. The worker function will execute on the selected priority
* worker thread. * worker thread.
* *
* Input Parameters: * Input Parameters:
* qid - Selects work queue. Must be HPWORK or LPWORK.
* worker - The worker function to execute on the high priority work queue * worker - The worker function to execute on the high priority work queue
* when the event occurs. * when the event occurs.
* arg - A user-defined argument that will be available to the worker * arg - A user-defined argument that will be available to the worker
@ -77,7 +78,7 @@
* *
****************************************************************************/ ****************************************************************************/
int iob_notifier_setup(worker_t worker, FAR void *arg) int iob_notifier_setup(int qid, worker_t worker, FAR void *arg)
{ {
struct work_notifier_s info; struct work_notifier_s info;
@ -95,7 +96,7 @@ int iob_notifier_setup(worker_t worker, FAR void *arg)
/* Otherwise, this is just a simple wrapper around work_notifer_setup(). */ /* Otherwise, this is just a simple wrapper around work_notifer_setup(). */
info.evtype = WORK_IOB_AVAIL; info.evtype = WORK_IOB_AVAIL;
info.wqueue = HPWORK; info.qid = qid;
info.qualifier = NULL; info.qualifier = NULL;
info.arg = arg; info.arg = arg;
info.worker = worker; info.worker = worker;

View File

@ -98,7 +98,7 @@ int netdown_notifier_setup(worker_t worker, FAR struct net_driver_s *dev,
/* Otherwise, this is just a simple wrapper around work_notifer_setup(). */ /* Otherwise, this is just a simple wrapper around work_notifer_setup(). */
info.evtype = WORK_NET_DOWN; info.evtype = WORK_NET_DOWN;
info.wqueue = LPWORK; info.qid = LPWORK;
info.qualifier = dev; info.qualifier = dev;
info.arg = arg; info.arg = arg;
info.worker = worker; info.worker = worker;

View File

@ -100,7 +100,7 @@ int tcp_readahead_notifier_setup(worker_t worker,
/* Otherwise, this is just a simple wrapper around work_notifer_setup(). */ /* Otherwise, this is just a simple wrapper around work_notifer_setup(). */
info.evtype = WORK_TCP_READAHEAD; info.evtype = WORK_TCP_READAHEAD;
info.wqueue = LPWORK; info.qid = LPWORK;
info.qualifier = conn; info.qualifier = conn;
info.arg = arg; info.arg = arg;
info.worker = worker; info.worker = worker;
@ -151,7 +151,7 @@ int tcp_readahead_disconnect_setup(worker_t worker,
/* Otherwise, this is just a simple wrapper around work_notifer_setup(). */ /* Otherwise, this is just a simple wrapper around work_notifer_setup(). */
info.evtype = WORK_TCP_DISCONNECT; info.evtype = WORK_TCP_DISCONNECT;
info.wqueue = LPWORK; info.qid = LPWORK;
info.qualifier = conn; info.qualifier = conn;
info.arg = arg; info.arg = arg;
info.worker = worker; info.worker = worker;

View File

@ -653,23 +653,22 @@ int udp_pollteardown(FAR struct socket *psock, FAR struct pollfd *fds);
* Description: * Description:
* Set up to perform a callback to the worker function when an UDP data * Set up to perform a callback to the worker function when an UDP data
* is added to the read-ahead buffer. The worker function will execute * is added to the read-ahead buffer. The worker function will execute
* on the high priority worker thread. * on the low priority worker thread.
* *
* Input Parameters: * Input Parameters:
* worker - The worker function to execute on the high priority work * worker - The worker function to execute on the low priority work
* queue when data is available in the UDP readahead buffer. * queue when data is available in the UDP read-ahead buffer.
* conn - The UDP connection where read-ahead data is needed. * conn - The UDP connection where read-ahead data is needed.
* arg - A user-defined argument that will be available to the worker * arg - A user-defined argument that will be available to the worker
* function when it runs. * function when it runs.
* *
* Returned Value: * Returned Value:
* > 0 - The signal notification is in place. The returned value is a * > 0 - The notification is in place. The returned value is a key that
* key that may be used later in a call to * may be used later in a call to udp_notifier_teardown().
* udp_notifier_teardown(). * == 0 - There is already buffered read-ahead data. No notification
* == 0 - There is already buffered read-ahead data. No signal * will be provided.
* notification will be provided. * < 0 - An unexpected error occurred and no notification will occur.
* < 0 - An unexpected error occurred and no signal will be sent. The * The returned value is a negated errno value that indicates the
* returned value is a negated errno value that indicates the
* nature of the failure. * nature of the failure.
* *
****************************************************************************/ ****************************************************************************/
@ -686,7 +685,7 @@ int udp_notifier_setup(worker_t worker, FAR struct udp_conn_s *conn,
* Eliminate a UDP read-ahead notification previously setup by * Eliminate a UDP read-ahead notification previously setup by
* udp_notifier_setup(). This function should only be called if the * udp_notifier_setup(). This function should only be called if the
* notification should be aborted prior to the notification. The * notification should be aborted prior to the notification. The
* notification will automatically be torn down after the signal is sent. * notification will automatically be torn down after the notification.
* *
* Input Parameters: * Input Parameters:
* key - The key value returned from a previous call to * key - The key value returned from a previous call to
@ -706,7 +705,7 @@ int udp_notifier_teardown(int key);
* Name: udp_notifier_signal * Name: udp_notifier_signal
* *
* Description: * Description:
* Read-ahead data has been buffered. Signal all threads waiting for * Read-ahead data has been buffered. Notify all threads waiting for
* read-ahead data to become available. * read-ahead data to become available.
* *
* When read-ahead data becomes available, *all* of the workers waiting * When read-ahead data becomes available, *all* of the workers waiting

View File

@ -59,22 +59,21 @@
* Description: * Description:
* Set up to perform a callback to the worker function when an UDP data * Set up to perform a callback to the worker function when an UDP data
* is added to the read-ahead buffer. The worker function will execute * is added to the read-ahead buffer. The worker function will execute
* on the high priority worker thread. * on the low priority worker thread.
* *
* Input Parameters: * Input Parameters:
* worker - The worker function to execute on the high priority work * worker - The worker function to execute on the low priority work
* queue when data is available in the UDP readahead buffer. * queue when data is available in the UDP read-ahead buffer.
* conn - The UDP connection where read-ahead data is needed. * conn - The UDP connection where read-ahead data is needed.
* arg - A user-defined argument that will be available to the worker * arg - A user-defined argument that will be available to the worker
* function when it runs. * function when it runs.
* *
* Returned Value: * Returned Value:
* > 0 - The signal notification is in place. The returned value is a * > 0 - The notification is in place. The returned value is a key that
* key that may be used later in a call to * may be used later in a call to udp_notifier_teardown().
* udp_notifier_teardown(). * == 0 - There is already buffered read-ahead data. No notification
* == 0 - There is already buffered read-ahead data. No signal * will be provided.
* notification will be provided. * < 0 - An unexpected error occurred and notification will occur. The
* < 0 - An unexpected error occurred and no signal will be sent. The
* returned value is a negated errno value that indicates the * returned value is a negated errno value that indicates the
* nature of the failure. * nature of the failure.
* *
@ -99,6 +98,7 @@ int udp_notifier_setup(worker_t worker, FAR struct udp_conn_s *conn,
/* Otherwise, this is just a simple wrapper around work_notifer_setup(). */ /* Otherwise, this is just a simple wrapper around work_notifer_setup(). */
info.evtype = WORK_UDP_READAHEAD; info.evtype = WORK_UDP_READAHEAD;
info.qid = LPWORK;
info.qualifier = conn; info.qualifier = conn;
info.arg = arg; info.arg = arg;
info.worker = worker; info.worker = worker;
@ -113,7 +113,7 @@ int udp_notifier_setup(worker_t worker, FAR struct udp_conn_s *conn,
* Eliminate a UDP read-ahead notification previously setup by * Eliminate a UDP read-ahead notification previously setup by
* udp_notifier_setup(). This function should only be called if the * udp_notifier_setup(). This function should only be called if the
* notification should be aborted prior to the notification. The * notification should be aborted prior to the notification. The
* notification will automatically be torn down after the signal is sent. * notification will automatically be torn down after the notification.
* *
* Input Parameters: * Input Parameters:
* key - The key value returned from a previous call to * key - The key value returned from a previous call to
@ -136,7 +136,7 @@ int udp_notifier_teardown(int key)
* Name: udp_notifier_signal * Name: udp_notifier_signal
* *
* Description: * Description:
* Read-ahead data has been buffered. Signal all threads waiting for * Read-ahead data has been buffered. Notify all threads waiting for
* read-ahead data to become available. * read-ahead data to become available.
* *
* When read-ahead data becomes available, *all* of the workers waiting * When read-ahead data becomes available, *all* of the workers waiting

View File

@ -1511,7 +1511,7 @@ config SCHED_LPNTHREADS
config SCHED_LPWORKPRIORITY config SCHED_LPWORKPRIORITY
int "Low priority worker thread priority" int "Low priority worker thread priority"
default 50 default 100
---help--- ---help---
The minimum execution priority of the lower priority worker thread. The minimum execution priority of the lower priority worker thread.
@ -1520,7 +1520,7 @@ config SCHED_LPWORKPRIORITY
priority, of course, but has the added advantage that it supports priority, of course, but has the added advantage that it supports
"priority inheritance" (if PRIORITY_INHERITANCE is also selected): "priority inheritance" (if PRIORITY_INHERITANCE is also selected):
The priority of the lower priority worker thread can then be The priority of the lower priority worker thread can then be
adjusted to match the highest priority client. Default: 50 adjusted to match the highest priority client. Default: 100
NOTE: This priority inheritance feature is not automatic. The NOTE: This priority inheritance feature is not automatic. The
lower priority worker thread will always a fixed priority unless lower priority worker thread will always a fixed priority unless

View File

@ -203,7 +203,7 @@ int work_notifier_setup(FAR struct work_notifier_s *info)
int ret; int ret;
DEBUGASSERT(info != NULL && info->worker != NULL); DEBUGASSERT(info != NULL && info->worker != NULL);
DEBUGASSERT(info->wqueue == HPWORK && info->wqueue == LPWORK); DEBUGASSERT(info->qid == HPWORK && info->qid == LPWORK);
/* Get exclusive access to the notifier data structures */ /* Get exclusive access to the notifier data structures */
@ -395,7 +395,7 @@ void work_notifier_signal(enum work_evtype_e evtype,
/* Schedule the work */ /* Schedule the work */
(void)work_queue(info->wqueue, &notifier->work, info->worker, (void)work_queue(info->qid, &notifier->work, info->worker,
info, 0); info, 0);
} }
else else