From dc5c9b3ae22bc039f889e3f3765c9ba080a6b3af Mon Sep 17 00:00:00 2001 From: patacongo Date: Mon, 14 May 2012 01:03:19 +0000 Subject: Add task switching instrumentation for missing case. Contributed by Petri Tanskanen. git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4734 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/sched/sched_mergepending.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'nuttx/sched') diff --git a/nuttx/sched/sched_mergepending.c b/nuttx/sched/sched_mergepending.c index 1448c0096..202228412 100644 --- a/nuttx/sched/sched_mergepending.c +++ b/nuttx/sched/sched_mergepending.c @@ -1,8 +1,8 @@ /************************************************************************ * sched/sched_mergepending.c * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. - * Author: Gregory Nutt + * Copyright (C) 2007, 2009, 2012 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -40,6 +40,7 @@ #include #include +#include #include #include @@ -135,24 +136,29 @@ bool sched_mergepending(void) rtrprev = rtrtcb->blink; if (!rtrprev) { - /* Special case: Inserting pndtcb at the head of the list */ + /* Special case: Inserting pndtcb at the head of the list */ + /* Inform the instrumentation layer that we are switching tasks */ - pndtcb->flink = rtrtcb; - pndtcb->blink = NULL; - rtrtcb->blink = pndtcb; - g_readytorun.head = (FAR dq_entry_t*)pndtcb; + sched_note_switch(rtrtcb, pndtcb); + + /* Then insert at the head of the list */ + + pndtcb->flink = rtrtcb; + pndtcb->blink = NULL; + rtrtcb->blink = pndtcb; + g_readytorun.head = (FAR dq_entry_t*)pndtcb; rtrtcb->task_state = TSTATE_TASK_READYTORUN; pndtcb->task_state = TSTATE_TASK_RUNNING; - ret = true; + ret = true; } else { /* Insert in the middle of the list */ - pndtcb->flink = rtrtcb; - pndtcb->blink = rtrprev; - rtrprev->flink = pndtcb; - rtrtcb->blink = pndtcb; + pndtcb->flink = rtrtcb; + pndtcb->blink = rtrprev; + rtrprev->flink = pndtcb; + rtrtcb->blink = pndtcb; pndtcb->task_state = TSTATE_TASK_READYTORUN; } } -- cgit v1.2.3