mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
Flesh out more cancellation point logic.
This commit is contained in:
@@ -62,7 +62,10 @@ pthread_mutex_init NXpthread_mutex_init
|
|||||||
pthread_mutex_lock NXpthread_mutex_lock
|
pthread_mutex_lock NXpthread_mutex_lock
|
||||||
pthread_mutex_unlock NXpthread_mutex_unlock
|
pthread_mutex_unlock NXpthread_mutex_unlock
|
||||||
pthread_setspecific NXpthread_setspecific
|
pthread_setspecific NXpthread_setspecific
|
||||||
|
pthread_setcancelstate NXpthread_setcancelstate
|
||||||
|
pthread_setcanceltype NXpthread_setcanceltype
|
||||||
pthread_sigmask NXpthread_sigmask
|
pthread_sigmask NXpthread_sigmask
|
||||||
|
pthread_testcancel NXpthread_testcancel
|
||||||
pthread_yield NXpthread_yield
|
pthread_yield NXpthread_yield
|
||||||
ptsname NXptsname
|
ptsname NXptsname
|
||||||
ptsname_r NXptsname_r
|
ptsname_r NXptsname_r
|
||||||
|
|||||||
@@ -218,6 +218,13 @@ int os_smp_start(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
up_initial_state(tcb);
|
up_initial_state(tcb);
|
||||||
|
|
||||||
|
/* Set the task flags to indicate that this is a kernel thread and that
|
||||||
|
* this task is locked to this CPU.
|
||||||
|
*/
|
||||||
|
|
||||||
|
tcb->flags = (TCB_FLAG_TTYPE_KERNEL | TCB_FLAG_NONCANCELABLE | TCB_FLAG_CPU_LOCKED);
|
||||||
|
tcb->cpu = cpu;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Then start all of the other CPUs after we have completed the memory
|
/* Then start all of the other CPUs after we have completed the memory
|
||||||
|
|||||||
@@ -470,10 +470,11 @@ void os_start(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
g_idletcb[cpu].cmn.flags = (TCB_FLAG_TTYPE_KERNEL | TCB_FLAG_CPU_LOCKED);
|
g_idletcb[cpu].cmn.flags = (TCB_FLAG_TTYPE_KERNEL TCB_FLAG_NONCANCELABLE |
|
||||||
|
TCB_FLAG_CPU_LOCKED);
|
||||||
g_idletcb[cpu].cmn.cpu = cpu;
|
g_idletcb[cpu].cmn.cpu = cpu;
|
||||||
#else
|
#else
|
||||||
g_idletcb[cpu].cmn.flags = TCB_FLAG_TTYPE_KERNEL;
|
g_idletcb[cpu].cmn.flags = (TCB_FLAG_TTYPE_KERNEL | TCB_FLAG_NONCANCELABLE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
#ifdef CONFIG_SMP
|
||||||
|
|||||||
@@ -42,6 +42,8 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/pthread.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -60,7 +62,6 @@
|
|||||||
|
|
||||||
void pthread_testcancel(void)
|
void pthread_testcancel(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_CANCELLATION_POINTS
|
enter_cancellation_point();
|
||||||
# warning Missing Logic
|
leave_cancellation_point();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,6 +44,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/sched.h>
|
#include <nuttx/sched.h>
|
||||||
|
#include <nuttx/pthread.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
|
|
||||||
@@ -84,4 +85,3 @@ pid_t wait(FAR int *stat_loc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_SCHED_WAITPID && CONFIG_SCHED_HAVE_PARENT */
|
#endif /* CONFIG_SCHED_WAITPID && CONFIG_SCHED_HAVE_PARENT */
|
||||||
|
|
||||||
|
|||||||
@@ -164,6 +164,10 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
|
|||||||
int errcode;
|
int errcode;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
/* waitid() is a cancellation point */
|
||||||
|
|
||||||
|
enter_cancellation_point();
|
||||||
|
|
||||||
/* MISSING LOGIC: If WNOHANG is provided in the options, then this function
|
/* MISSING LOGIC: If WNOHANG is provided in the options, then this function
|
||||||
* should returned immediately. However, there is no mechanism available now
|
* should returned immediately. However, there is no mechanism available now
|
||||||
* know if the thread has child: The children remember their parents (if
|
* know if the thread has child: The children remember their parents (if
|
||||||
@@ -404,12 +408,14 @@ int waitid(idtype_t idtype, id_t id, FAR siginfo_t *info, int options)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leave_cancellation_point();
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
return OK;
|
return OK;
|
||||||
|
|
||||||
errout_with_errno:
|
errout_with_errno:
|
||||||
set_errno(errcode);
|
set_errno(errcode);
|
||||||
errout:
|
errout:
|
||||||
|
leave_cancellation_point();
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,6 +45,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/sched.h>
|
#include <nuttx/sched.h>
|
||||||
|
#include <nuttx/pthread.h>
|
||||||
|
|
||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "group/group.h"
|
#include "group/group.h"
|
||||||
@@ -185,12 +186,17 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
|
|||||||
|
|
||||||
DEBUGASSERT(stat_loc);
|
DEBUGASSERT(stat_loc);
|
||||||
|
|
||||||
|
/* waitpid() is a cancellation point */
|
||||||
|
|
||||||
|
enter_cancellation_point();
|
||||||
|
|
||||||
/* None of the options are supported */
|
/* None of the options are supported */
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FEATURES
|
#ifdef CONFIG_DEBUG_FEATURES
|
||||||
if (options != 0)
|
if (options != 0)
|
||||||
{
|
{
|
||||||
set_errno(ENOSYS);
|
set_errno(ENOSYS);
|
||||||
|
leave_cancellation_point();
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -268,12 +274,14 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
|
|||||||
|
|
||||||
/* On success, return the PID */
|
/* On success, return the PID */
|
||||||
|
|
||||||
|
leave_cancellation_point();
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
return pid;
|
return pid;
|
||||||
|
|
||||||
errout_with_errno:
|
errout_with_errno:
|
||||||
set_errno(errcode);
|
set_errno(errcode);
|
||||||
errout:
|
errout:
|
||||||
|
leave_cancellation_point();
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
@@ -307,12 +315,17 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
|
|||||||
|
|
||||||
DEBUGASSERT(stat_loc);
|
DEBUGASSERT(stat_loc);
|
||||||
|
|
||||||
|
/* waitpid() is a cancellation point */
|
||||||
|
|
||||||
|
enter_cancellation_point();
|
||||||
|
|
||||||
/* None of the options are supported */
|
/* None of the options are supported */
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG_FEATURES
|
#ifdef CONFIG_DEBUG_FEATURES
|
||||||
if (options != 0)
|
if (options != 0)
|
||||||
{
|
{
|
||||||
set_errno(ENOSYS);
|
set_errno(ENOSYS);
|
||||||
|
leave_cancellation_point();
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -528,6 +541,7 @@ pid_t waitpid(pid_t pid, int *stat_loc, int options)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leave_cancellation_point();
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
return (int)pid;
|
return (int)pid;
|
||||||
|
|
||||||
@@ -535,6 +549,7 @@ errout_with_errno:
|
|||||||
set_errno(errcode);
|
set_errno(errcode);
|
||||||
|
|
||||||
errout_with_lock:
|
errout_with_lock:
|
||||||
|
leave_cancellation_point();
|
||||||
sched_unlock();
|
sched_unlock();
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -86,6 +86,10 @@ int sem_wait(FAR sem_t *sem)
|
|||||||
|
|
||||||
DEBUGASSERT(sem != NULL && up_interrupt_context() == false);
|
DEBUGASSERT(sem != NULL && up_interrupt_context() == false);
|
||||||
|
|
||||||
|
/* sem_wait is a cancellation point */
|
||||||
|
|
||||||
|
enter_cancellation_point();
|
||||||
|
|
||||||
/* Make sure we were supplied with a valid semaphore. */
|
/* Make sure we were supplied with a valid semaphore. */
|
||||||
|
|
||||||
if (sem != NULL)
|
if (sem != NULL)
|
||||||
@@ -196,5 +200,6 @@ int sem_wait(FAR sem_t *sem)
|
|||||||
set_errno(EINVAL);
|
set_errno(EINVAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
leave_cancellation_point();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user