tree: convert to evl_set/clear_thread_mode()

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
This commit is contained in:
Philippe Gerum 2020-04-22 20:08:58 +02:00
parent dbb8d32f08
commit 928717d5cc
8 changed files with 19 additions and 30 deletions

View File

@ -382,17 +382,15 @@ static void *timer_responder(void *arg)
__u64 timestamp = 0; __u64 timestamp = 0;
struct timespec now; struct timespec now;
int ret, efd; int ret, efd;
__u32 mode;
/* Make it a public thread only for demo purpose. */ /* Make it a public thread only for demo purpose. */
efd = evl_attach_self("/timer-responder:%d", getpid()); efd = evl_attach_self("/timer-responder:%d", getpid());
if (efd < 0) if (efd < 0)
error(1, -efd, "evl_attach_self() failed"); error(1, -efd, "evl_attach_self() failed");
mode = T_WOSS; ret = evl_set_thread_mode(efd, T_WOSS, NULL);
ret = oob_ioctl(efd, EVL_THRIOC_SET_MODE, &mode);
if (ret) if (ret)
error(1, errno, "ioctl(EVL_THRIOC_SET_MODE) failed"); error(1, -ret, "evl_set_thread_mode(T_WOSS) failed");
for (;;) { for (;;) {
ret = oob_ioctl(latmus_fd, EVL_LATIOC_PULSE, &timestamp); ret = oob_ioctl(latmus_fd, EVL_LATIOC_PULSE, &timestamp);
@ -519,7 +517,6 @@ static void *gpio_responder_thread(void *arg)
typeof(read) *do_read; typeof(read) *do_read;
const int ackval = 0; /* Remote observes falling edges. */ const int ackval = 0; /* Remote observes falling edges. */
int fds[2], efd, ret; int fds[2], efd, ret;
__u32 mode;
setup_gpio_pins(fds); setup_gpio_pins(fds);
@ -528,10 +525,9 @@ static void *gpio_responder_thread(void *arg)
if (efd < 0) if (efd < 0)
error(1, -efd, "evl_attach_self() failed"); error(1, -efd, "evl_attach_self() failed");
mode = T_WOSS; ret = evl_set_thread_mode(efd, T_WOSS, NULL);
ret = oob_ioctl(efd, EVL_THRIOC_SET_MODE, &mode);
if (ret) if (ret)
error(1, errno, "ioctl(EVL_THRIOC_SET_MODE) failed"); error(1, -ret, "evl_set_thread_mode(T_WOSS) failed");
do_ioctl = oob_ioctl; do_ioctl = oob_ioctl;
do_read = oob_read; do_read = oob_read;

View File

@ -36,7 +36,6 @@ int main(int argc, char *argv[])
struct sched_param param; struct sched_param param;
struct sigaction sa; struct sigaction sa;
int tfd, ret; int tfd, ret;
__u32 mode;
double f; double f;
srand(time(NULL)); srand(time(NULL));
@ -50,13 +49,12 @@ int main(int argc, char *argv[])
SCHED_FIFO, &param) == 0); SCHED_FIFO, &param) == 0);
__Tcall_assert(tfd, evl_attach_self("fpu-preload:%d", getpid())); __Tcall_assert(tfd, evl_attach_self("fpu-preload:%d", getpid()));
mode = T_WOSS; __Tcall_assert(ret, evl_set_thread_mode(tfd, T_WOSS, NULL));
__Tcall_errno_assert(ret, oob_ioctl(tfd, EVL_THRIOC_SET_MODE, &mode));
f = get_float() * get_float(); f = get_float() * get_float();
__Tcall_errno_assert(ret, oob_ioctl(tfd, EVL_THRIOC_CLEAR_MODE, &mode)); __Tcall_assert(ret, evl_clear_thread_mode(tfd, T_WOSS, NULL));
if (fork() == 0) { if (fork() == 0) {
__Tcall_assert(tfd, evl_attach_self("fpu-preload-child:%d", getpid())); __Tcall_assert(tfd, evl_attach_self("fpu-preload-child:%d", getpid()));
__Tcall_errno_assert(ret, oob_ioctl(tfd, EVL_THRIOC_SET_MODE, &mode)); __Tcall_assert(ret, evl_set_thread_mode(tfd, T_WOSS, NULL));
f = get_float() * get_float(); f = get_float() * get_float();
} }

View File

@ -29,14 +29,14 @@ struct test_context {
static void *deadlocking_thread(void *arg) static void *deadlocking_thread(void *arg)
{ {
struct test_context *p = arg; struct test_context *p = arg;
int ret, tfd, mode = T_WOLI; int ret, tfd;
__Tcall_assert(tfd, evl_attach_self("monitor-dlk-B:%d", getpid())); __Tcall_assert(tfd, evl_attach_self("monitor-dlk-B:%d", getpid()));
/* /*
* Disable WOLI in case CONFIG_EVL_DEBUG_WOLI is set, as we * Disable WOLI in case CONFIG_EVL_DEBUG_WOLI is set, as we
* are about to sleep while holding a mutex. * are about to sleep while holding a mutex.
*/ */
__Tcall_errno_assert(ret, oob_ioctl(tfd, EVL_THRIOC_CLEAR_MODE, &mode)); __Tcall_assert(ret, evl_clear_thread_mode(tfd, T_WOLI, NULL));
__Tcall_assert(ret, evl_lock_mutex(&p->lock_b)); __Tcall_assert(ret, evl_lock_mutex(&p->lock_b));
__Tcall_assert(ret, evl_put_sem(&p->sync)); __Tcall_assert(ret, evl_put_sem(&p->sync));
__Tcall_assert(ret, evl_get_sem(&p->start)); __Tcall_assert(ret, evl_get_sem(&p->start));
@ -49,8 +49,8 @@ static void *deadlocking_thread(void *arg)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int tfd, gfd, sfd, ret, mode = T_WOLI;
struct sched_param param; struct sched_param param;
int tfd, gfd, sfd, ret;
struct test_context c; struct test_context c;
pthread_t deadlocker; pthread_t deadlocker;
char *name; char *name;
@ -80,7 +80,7 @@ int main(int argc, char *argv[])
* Disable WOLI in case CONFIG_EVL_DEBUG_WOLI is set, as we * Disable WOLI in case CONFIG_EVL_DEBUG_WOLI is set, as we
* are about to sleep while holding a mutex. * are about to sleep while holding a mutex.
*/ */
__Tcall_errno_assert(ret, oob_ioctl(tfd, EVL_THRIOC_CLEAR_MODE, &mode)); __Tcall_assert(ret, evl_clear_thread_mode(tfd, T_WOLI, NULL));
__Tcall_assert(ret, evl_lock_mutex(&c.lock_a)); __Tcall_assert(ret, evl_lock_mutex(&c.lock_a));
__Fcall_assert(ret, evl_lock_mutex(&c.lock_a)); /* stupid deadlock */ __Fcall_assert(ret, evl_lock_mutex(&c.lock_a)); /* stupid deadlock */
__Texpr_assert(ret == -EDEADLK); __Texpr_assert(ret == -EDEADLK);

View File

@ -40,10 +40,7 @@ static void *event_receiver(void *arg)
* Disable WOLI in case CONFIG_EVL_DEBUG_WOLI is set, as we * Disable WOLI in case CONFIG_EVL_DEBUG_WOLI is set, as we
* are about to sleep while holding a mutex. * are about to sleep while holding a mutex.
*/ */
{ __Tcall_assert(ret, evl_clear_thread_mode(receiverfd, T_WOLI, NULL));
int mode = T_WOLI;
__Tcall_errno_assert(ret, oob_ioctl(receiverfd, EVL_THRIOC_CLEAR_MODE, &mode));
}
#endif #endif
__Tcall_assert(ret, evl_get_sem(&p->start)); __Tcall_assert(ret, evl_get_sem(&p->start));
evl_read_clock(EVL_CLOCK_MONOTONIC, &now); evl_read_clock(EVL_CLOCK_MONOTONIC, &now);

View File

@ -30,14 +30,14 @@ struct test_context {
static void *deadlocking_thread(void *arg) static void *deadlocking_thread(void *arg)
{ {
struct test_context *p = arg; struct test_context *p = arg;
int ret, tfd, mode = T_WOLI; int ret, tfd;
__Tcall_assert(tfd, evl_attach_self("monitor-pi-dlk-B:%d", getpid())); __Tcall_assert(tfd, evl_attach_self("monitor-pi-dlk-B:%d", getpid()));
/* /*
* Disable WOLI in case CONFIG_EVL_DEBUG_WOLI is set, as we * Disable WOLI in case CONFIG_EVL_DEBUG_WOLI is set, as we
* are about to sleep while holding a mutex. * are about to sleep while holding a mutex.
*/ */
__Tcall_errno_assert(ret, oob_ioctl(tfd, EVL_THRIOC_CLEAR_MODE, &mode)); __Tcall_assert(ret, evl_clear_thread_mode(tfd, T_WOLI, NULL));
__Tcall_assert(ret, evl_lock_mutex(&p->lock_b)); __Tcall_assert(ret, evl_lock_mutex(&p->lock_b));
__Tcall_assert(ret, evl_put_sem(&p->sync)); __Tcall_assert(ret, evl_put_sem(&p->sync));
__Tcall_assert(ret, evl_get_sem(&p->start)); __Tcall_assert(ret, evl_get_sem(&p->start));

View File

@ -57,8 +57,8 @@ static bool check_priority(int tfd, int prio)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int tfd, gfd, sfd, ret, mode = T_WOLI;
struct sched_param param; struct sched_param param;
int tfd, gfd, sfd, ret;
struct test_context c; struct test_context c;
pthread_t contender; pthread_t contender;
void *status = NULL; void *status = NULL;
@ -87,7 +87,7 @@ int main(int argc, char *argv[])
* Disable WOLI in case CONFIG_EVL_DEBUG_WOLI is set, as we * Disable WOLI in case CONFIG_EVL_DEBUG_WOLI is set, as we
* are about to sleep while holding a mutex. * are about to sleep while holding a mutex.
*/ */
__Tcall_errno_assert(ret, oob_ioctl(tfd, EVL_THRIOC_CLEAR_MODE, &mode)); __Tcall_assert(ret, evl_clear_thread_mode(tfd, T_WOLI, NULL));
__Tcall_assert(ret, evl_lock_mutex(&c.lock)); __Tcall_assert(ret, evl_lock_mutex(&c.lock));
__Tcall_assert(ret, evl_put_sem(&c.start)); __Tcall_assert(ret, evl_put_sem(&c.start));
__Tcall_assert(ret, evl_get_sem(&c.sem)); __Tcall_assert(ret, evl_get_sem(&c.sem));

View File

@ -58,9 +58,9 @@ static bool check_priority(int tfd, int prio)
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int tfd, gfd, sfd, ret, mode = T_WOLI;
struct sched_param param; struct sched_param param;
struct evl_mutex lock_pp; struct evl_mutex lock_pp;
int tfd, gfd, sfd, ret;
struct test_context c; struct test_context c;
pthread_t contender; pthread_t contender;
void *status = NULL; void *status = NULL;
@ -93,7 +93,7 @@ int main(int argc, char *argv[])
* Disable WOLI in case CONFIG_EVL_DEBUG_WOLI is set, as we * Disable WOLI in case CONFIG_EVL_DEBUG_WOLI is set, as we
* are about to sleep while holding a mutex. * are about to sleep while holding a mutex.
*/ */
__Tcall_errno_assert(ret, oob_ioctl(tfd, EVL_THRIOC_CLEAR_MODE, &mode)); __Tcall_assert(ret, evl_clear_thread_mode(tfd, T_WOLI, NULL));
__Tcall_assert(ret, evl_lock_mutex(&lock_pp)); __Tcall_assert(ret, evl_lock_mutex(&lock_pp));
__Tcall_assert(ret, evl_usleep(5000)); /* Commit PP boost. */ __Tcall_assert(ret, evl_usleep(5000)); /* Commit PP boost. */
__Texpr_assert(check_priority(tfd, MEDIUM_PRIO)); __Texpr_assert(check_priority(tfd, MEDIUM_PRIO));

View File

@ -38,11 +38,9 @@ static void sigdebug_handler(int sig, siginfo_t *si, void *context)
static void *test_thread(void *arg) static void *test_thread(void *arg)
{ {
int tfd, ret; int tfd, ret;
__u32 mode;
__Tcall_assert(tfd, evl_attach_self("stax-warn-test:%d", getpid())); __Tcall_assert(tfd, evl_attach_self("stax-warn-test:%d", getpid()));
mode = T_WOSX; __Tcall_assert(ret, evl_set_thread_mode(tfd, T_WOSX, NULL));
__Tcall_errno_assert(ret, oob_ioctl(tfd, EVL_THRIOC_SET_MODE, &mode));
/* /*
* In-band main() currently holds the stax, we should get * In-band main() currently holds the stax, we should get