mirror of
https://github.com/apache/nuttx.git
synced 2026-05-26 18:56:10 +08:00
userspace/wqueue: move exclusive access lock to mqueue inside
Change-Id: I885d5641bc81fedf698c241d4719cb3561700f17 Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
@@ -77,14 +77,6 @@
|
||||
|
||||
struct usr_wqueue_s g_usrwork;
|
||||
|
||||
/* This semaphore supports exclusive access to the user-mode work queue */
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
sem_t g_usrsem;
|
||||
#else
|
||||
pthread_mutex_t g_usrmutex;
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
@@ -125,7 +117,7 @@ void work_process(FAR struct usr_wqueue_s *wqueue)
|
||||
*/
|
||||
|
||||
next = WORK_DELAY_MAX;
|
||||
ret = work_lock();
|
||||
ret = _SEM_WAIT(&wqueue->lock);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out earlier if we were awakened by a signal */
|
||||
@@ -188,7 +180,7 @@ void work_process(FAR struct usr_wqueue_s *wqueue)
|
||||
* performed... we don't have any idea how long this will take!
|
||||
*/
|
||||
|
||||
work_unlock();
|
||||
_SEM_POST(&wqueue->lock);
|
||||
worker(arg);
|
||||
|
||||
/* Now, unfortunately, since we unlocked the work queue we
|
||||
@@ -196,7 +188,7 @@ void work_process(FAR struct usr_wqueue_s *wqueue)
|
||||
* start back at the head of the list.
|
||||
*/
|
||||
|
||||
ret = work_lock();
|
||||
ret = _SEM_WAIT(&wqueue->lock);
|
||||
if (ret < 0)
|
||||
{
|
||||
/* Break out earlier if we were awakened by a signal */
|
||||
@@ -255,7 +247,7 @@ void work_process(FAR struct usr_wqueue_s *wqueue)
|
||||
*/
|
||||
|
||||
sigprocmask(SIG_BLOCK, &sigset, &oldset);
|
||||
work_unlock();
|
||||
_SEM_POST(&wqueue->lock);
|
||||
|
||||
if (next == WORK_DELAY_MAX)
|
||||
{
|
||||
@@ -347,10 +339,11 @@ static pthread_addr_t work_usrthread(pthread_addr_t arg)
|
||||
|
||||
int work_usrstart(void)
|
||||
{
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
/* Set up the work queue lock */
|
||||
|
||||
_SEM_INIT(&g_usrsem, 0, 1);
|
||||
_SEM_INIT(&g_usrwork.lock, 0, 1);
|
||||
|
||||
#ifdef CONFIG_BUILD_PROTECTED
|
||||
|
||||
/* Start a user-mode worker thread for use by applications. */
|
||||
|
||||
@@ -375,10 +368,6 @@ int work_usrstart(void)
|
||||
struct sched_param param;
|
||||
int ret;
|
||||
|
||||
/* Set up the work queue lock */
|
||||
|
||||
pthread_mutex_init(&g_usrmutex, NULL);
|
||||
|
||||
/* Start a user-mode worker thread for use by applications. */
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
|
||||
Reference in New Issue
Block a user