From 3bcc691f1cdde5ffc32b01346309877571684d8d Mon Sep 17 00:00:00 2001 From: NicJA Date: Fri, 8 May 2015 01:07:32 +0000 Subject: [PATCH] use new version of the macros - and add wip changes for newaddtask and remtask git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@50623 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- rom/exec/newaddtask.c | 9 ++++++++- rom/exec/prepareexecbase.c | 6 +++--- rom/exec/remtask.c | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/rom/exec/newaddtask.c b/rom/exec/newaddtask.c index 6b9f604c45..b253aa4eec 100644 --- a/rom/exec/newaddtask.c +++ b/rom/exec/newaddtask.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2011, The AROS Development Team. All rights reserved. + Copyright © 1995-2015, The AROS Development Team. All rights reserved. $Id$ Desc: Add a task. @@ -174,11 +174,18 @@ of Signal() which is usable from interrupts and may change those lists. */ + +#if defined(__AROSEXEC_SMP__) + EXEC_SPINLOCK_LOCK(&PrivExecBase(SysBase)->TaskReadySpinLock, SPINLOCK_MODE_WRITE); +#endif Disable(); /* Add the new task to the ready list. */ task->tc_State=TS_READY; Enqueue(&SysBase->TaskReady,&task->tc_Node); +#if defined(__AROSEXEC_SMP__) + EXEC_SPINLOCK_UNLOCK(&PrivExecBase(SysBase)->TaskReadySpinLock); +#endif /* Determine if a task switch is necessary. (If the new task has a diff --git a/rom/exec/prepareexecbase.c b/rom/exec/prepareexecbase.c index 19d4bf2d73..c5824e0a69 100644 --- a/rom/exec/prepareexecbase.c +++ b/rom/exec/prepareexecbase.c @@ -306,10 +306,10 @@ struct ExecBase *PrepareExecBase(struct MemHeader *mh, struct TagItem *msg) NEWLIST(&PrivExecBase(SysBase)->TaskStorageSlots); #if defined(__AROSEXEC_SMP__) - EXEC_SPINLOCK_INIT(&PrivExecBase(SysBase)->TaskRunningSpinLock, NULL); + EXEC_SPINLOCK_INIT(&PrivExecBase(SysBase)->TaskRunningSpinLock); NEWLIST(&PrivExecBase(SysBase)->TaskRunning); - EXEC_SPINLOCK_INIT(&PrivExecBase(SysBase)->TaskReadySpinLock, NULL); - EXEC_SPINLOCK_INIT(&PrivExecBase(SysBase)->TaskWaitSpinLock, NULL); + EXEC_SPINLOCK_INIT(&PrivExecBase(SysBase)->TaskReadySpinLock); + EXEC_SPINLOCK_INIT(&PrivExecBase(SysBase)->TaskWaitSpinLock); #endif SetSysBaseChkSum(); diff --git a/rom/exec/remtask.c b/rom/exec/remtask.c index 960c43f89d..839b151336 100644 --- a/rom/exec/remtask.c +++ b/rom/exec/remtask.c @@ -14,6 +14,7 @@ #include #include +#include "etask.h" #include "exec_intern.h" #include "exec_util.h" #include "exec_debug.h" @@ -61,6 +62,9 @@ struct MemList *mb; struct ETask *et; BOOL suicide; +#if defined(__AROSEXEC_SMP__) + spinlock_t *task_listlock = NULL; +#endif /* A value of NULL means current task */ if (task==NULL) @@ -70,7 +74,9 @@ /* Don't let any other task interfere with us at the moment */ +#if !defined(__AROSEXEC_SMP__) Forbid(); +#endif suicide = (task == GET_THIS_TASK); if (suicide) @@ -80,7 +86,28 @@ the MemEntry list might contain the task struct itself! */ if (!suicide) + { +#if defined(__AROSEXEC_SMP__) + switch (task->tc_State) + { + case TS_RUN: + task_listlock =&PrivExecBase(SysBase)->TaskRunningSpinLock; + break; + case TS_WAIT: + task_listlock = &PrivExecBase(SysBase)->TaskWaitSpinLock; + break; + default: + task_listlock = &PrivExecBase(SysBase)->TaskReadySpinLock; + break; + } + EXEC_SPINLOCK_LOCK(task_listlock, SPINLOCK_MODE_WRITE); + Disable(); +#endif Remove(&task->tc_Node); +#if defined(__AROSEXEC_SMP__) + EXEC_SPINLOCK_UNLOCK(task_listlock); +#endif + } /* * The task is being removed. @@ -111,8 +138,10 @@ InternalPutMsg(((struct IntExecBase *)SysBase)->ServicePort, (struct Message *)task, SysBase); +#if !defined(__AROSEXEC_SMP__) /* Changing the task lists always needs a Disable(). */ Disable(); +#endif /* Since I don't know how many levels of Forbid() @@ -140,7 +169,12 @@ } /* All done. */ +#if defined(__AROSEXEC_SMP__) + if (task_listlock) + Enable(); +#else Permit(); +#endif DREMTASK("Success"); -- 2.11.4.GIT