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
This commit is contained in:
patacongo
2012-05-14 01:03:19 +00:00
parent 0a5b65743c
commit 981846cb54
2 changed files with 20 additions and 12 deletions
+2
View File
@@ -2758,3 +2758,5 @@
are multiple queued touchscreen events for the same window and (2) the result of the are multiple queued touchscreen events for the same window and (2) the result of the
first input was to switch windows, then the autoraise implementation will cause the first input was to switch windows, then the autoraise implementation will cause the
window to revert to the previous window. Not good behavior. window to revert to the previous window. Not good behavior.
* sched/sched_mergepending.c: Add task switching instrumentation. There is a case
here where instrumentation was missing. Contributed by Petri Tanskanen.
+18 -12
View File
@@ -1,8 +1,8 @@
/************************************************************************ /************************************************************************
* sched/sched_mergepending.c * sched/sched_mergepending.c
* *
* Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. * Copyright (C) 2007, 2009, 2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@@ -40,6 +40,7 @@
#include <nuttx/config.h> #include <nuttx/config.h>
#include <stdbool.h> #include <stdbool.h>
#include <sched.h>
#include <queue.h> #include <queue.h>
#include <assert.h> #include <assert.h>
@@ -135,24 +136,29 @@ bool sched_mergepending(void)
rtrprev = rtrtcb->blink; rtrprev = rtrtcb->blink;
if (!rtrprev) 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; sched_note_switch(rtrtcb, pndtcb);
pndtcb->blink = NULL;
rtrtcb->blink = pndtcb; /* Then insert at the head of the list */
g_readytorun.head = (FAR dq_entry_t*)pndtcb;
pndtcb->flink = rtrtcb;
pndtcb->blink = NULL;
rtrtcb->blink = pndtcb;
g_readytorun.head = (FAR dq_entry_t*)pndtcb;
rtrtcb->task_state = TSTATE_TASK_READYTORUN; rtrtcb->task_state = TSTATE_TASK_READYTORUN;
pndtcb->task_state = TSTATE_TASK_RUNNING; pndtcb->task_state = TSTATE_TASK_RUNNING;
ret = true; ret = true;
} }
else else
{ {
/* Insert in the middle of the list */ /* Insert in the middle of the list */
pndtcb->flink = rtrtcb; pndtcb->flink = rtrtcb;
pndtcb->blink = rtrprev; pndtcb->blink = rtrprev;
rtrprev->flink = pndtcb; rtrprev->flink = pndtcb;
rtrtcb->blink = pndtcb; rtrtcb->blink = pndtcb;
pndtcb->task_state = TSTATE_TASK_READYTORUN; pndtcb->task_state = TSTATE_TASK_READYTORUN;
} }
} }