Skip to contentSkip to conversation

Question about task_struct::state

PATCH Dhaval Giani 2 participants 2 messages Jun 10, 2008 Scheduler

lore
Share & tools
lore
#0 lore raw

Hi Ingo, Oleg,

sched.h has a comment in task_struct

volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */

After some searching, I've not been able to figure out how state can become -1 (or unrunnable). Can you let me know how that happens?

If it cannot reach that state, then maybe this patch is needed.

include/linux/sched.h +1 -1
Index: linux-2.6/include/linux/sched.h
===================================================================
@@ -1024,7 +1024,7 @@ struct sched_rt_entity {
 };
 
 struct task_struct {
-	volatile long state;	/* -1 unrunnable, 0 runnable, >0 stopped */
+	volatile long state;	/* 0 runnable, >0 stopped */
 	void *stack;
 	atomic_t usage;
 	unsigned int flags;	/* per process flags, defined below */
Signature · 2 lines
regards,
Dhaval
#1 lore raw
Quoted 17 lines · Dhaval Giani

sched.h has a comment in task_struct

volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */

After some searching, I've not been able to figure out how state can become -1 (or unrunnable). Can you let me know how that happens?

If it cannot reach that state, then maybe this patch is needed.

Index: linux-2.6/include/linux/sched.h
===================================================================

include/linux/sched.h struct sched_rt_entity { · line 1027

Quoted 5 lines
include/linux/sched.h +1 -1
@@ -1024,7 +1024,7 @@ struct sched_rt_entity {
 };
 
 struct task_struct {
-	volatile long state;	/* -1 unrunnable, 0 runnable, >0 stopped */
+	volatile long state;	/* 0 runnable, >0 stopped */

I think you are right, the comment is wrong (obsolete?).

Perhaps it is better to just remove it, or add a note about TASK_RUNNING/etc above. ">0 stopped" looks a bit confusing too.

I'd suggest you to change the subject and send the patch to Andrew.

Oleg.