From 3be307bc25e9ff271a3ca50e8396aacc8ffdd87f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 18 Feb 2014 11:50:32 -0600 Subject: [PATCH] sched/task_terminate always return an error because return value was not being set correctory. From Gosha --- ChangeLog | 2 ++ configs/samd20-xplained/README.txt | 4 ++-- sched/sched_releasetcb.c | 1 - sched/task_exit.c | 7 ++++--- sched/task_terminate.c | 13 ++++++------- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4aceaf6f0d..4a8390ab84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6586,4 +6586,6 @@ connecting to a server (2014-2-15). * The basic SAMD20 Xplained Pro port is complete but still untested (2014-2-16). + * sched/task_terminate.c: Always returns an error because the + return value was not being set correctly. From Gosha (2014-2-18). diff --git a/configs/samd20-xplained/README.txt b/configs/samd20-xplained/README.txt index 6ca8809324..81962e5907 100644 --- a/configs/samd20-xplained/README.txt +++ b/configs/samd20-xplained/README.txt @@ -852,7 +852,7 @@ Configuration sub-directories STATUS/ISSUES: - 1. The FLASH waistates is set to 2 (see include/board.h). According to + 1. The FLASH waitstates is set to 2 (see include/board.h). According to the data sheet, it should work at 1 but I sometimes see crashes when the waitstates are set to one (about half of the time) (2014-2-18). @@ -860,7 +860,7 @@ Configuration sub-directories the time) or after a power cycle (less after a power cycle). I don't understand the cause of of this but most of this can be eliminated by simply holding the the reset button longer and releasing it cleanly - (then it fails maybe 5-10% of the time, mabe because of button + (then it fails maybe 5-10% of the time, maybe because of button chatter?) (2014-2-18). - The garbage is not random: It is always the same. diff --git a/sched/sched_releasetcb.c b/sched/sched_releasetcb.c index b0605ef3bd..26476ec987 100644 --- a/sched/sched_releasetcb.c +++ b/sched/sched_releasetcb.c @@ -198,4 +198,3 @@ int sched_releasetcb(FAR struct tcb_s *tcb, uint8_t ttype) return ret; } - diff --git a/sched/task_exit.c b/sched/task_exit.c index 031b22ed85..9483f65fd7 100644 --- a/sched/task_exit.c +++ b/sched/task_exit.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/task_exit.c * - * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2012-2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -105,6 +105,7 @@ int task_exit(void) { FAR struct tcb_s *dtcb = (FAR struct tcb_s*)g_readytorun.head; FAR struct tcb_s *rtcb; + int ret; /* Remove the TCB of the current task from the ready-to-run list. A context * switch will definitely be necessary -- that must be done by the @@ -136,7 +137,7 @@ int task_exit(void) */ sched_addblocked(dtcb, TSTATE_TASK_INACTIVE); - task_terminate(dtcb->pid, true); + ret = task_terminate(dtcb->pid, true); rtcb->task_state = TSTATE_TASK_RUNNING; /* If there are any pending tasks, then add them to the ready-to-run @@ -157,5 +158,5 @@ int task_exit(void) */ rtcb->lockcount--; - return OK; + return ret; } diff --git a/sched/task_terminate.c b/sched/task_terminate.c index af8915d33a..9d034d7195 100644 --- a/sched/task_terminate.c +++ b/sched/task_terminate.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/task_terminate.c * - * Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -123,7 +124,6 @@ int task_terminate(pid_t pid, bool nonblocking) { FAR struct tcb_s *dtcb; irqstate_t saved_state; - int ret = ERROR; /* Make sure the task does not become ready-to-run while we are futzing with * its TCB by locking ourselves as the executing task. @@ -131,15 +131,15 @@ int task_terminate(pid_t pid, bool nonblocking) sched_lock(); - /* Find for the TCB associated with matching pid */ + /* Find for the TCB associated with matching PID */ dtcb = sched_gettcb(pid); if (!dtcb) { - /* This pid does not correspond to any known task */ + /* This PID does not correspond to any known task */ sched_unlock(); - return ERROR; + return -ESRCH; } /* Verify our internal sanity */ @@ -184,6 +184,5 @@ int task_terminate(pid_t pid, bool nonblocking) /* Deallocate its TCB */ - sched_releasetcb(dtcb, dtcb->flags & TCB_FLAG_TTYPE_MASK); - return ret; + return sched_releasetcb(dtcb, dtcb->flags & TCB_FLAG_TTYPE_MASK); }