sched.c function
Quoted 5 lines
Tasks do not change their state without holding a lock. (There is an exception,
but it is justified.)
list after that..
Quoted 6 lines
So you want to record task state changes? That is better done at the right
places in the kernel rather than traversing the task list repeatedly (the
latter is not that performant).
So you want to say that only one task could be running at a single time
but how to know which one
is there any way without traversing the task list previously i thought of for_each_process(p)
if(p->state==running)
but without this how to find which process is currently running and other are sleeping
may it is through "current"
since the current->pid is only running
but i have to run this repeatedly to get the information of currently running process(since this may be for a fraction of a second and i can miss that process if my loop is longer)
how to do that
fast timer
or any other way
i am little bit confused
Quoted 3 lines
I would be interested in the background: what do you need to know the task
states for?
i want to develop a task manager for threads. the application reads properly the process information and the thread information but not able to refresh the thread information as i am building my own proc file where only threads are there
i am distinguishing between process and thread at fork.c
with clone_vm set..
therefore i need to know which thread is currently running or not
there is another problem i am discusing with you
i want to distinguish between thread and process and after distinguishing between user thread and kernel thread
but i am unable to find any condition which will be true for kernel level thread during creation and false for user level thread
can you help me in this also
thanks
sounak
________________________________________________________________________
Yahoo! India Matrimony: Find your partner online. http://yahoo.shaadi.com/india-matrimony/
Quoted 2 lines
So you want to say that only one task could be running at a single time
per processor, yes.
Quoted 1 line
but how to know which one
The kernel is not a separate task. If you call read() for example, you change from user to kernel space, so there can be multiple threads being in kernel space at the same time (on SMP+) -- there is no process that is _always_ in kernelspace.
task_t *current;
is a pointer to the, well, current process (remember that the kernel is not a separate proc!)
Quoted 3 lines
is there any way without traversing the task list previously i thought of
for_each_process(p)if(p->state==running)
Good idea.
Quoted 3 lines
but without this how to find which process is currently running and other are sleeping
may it is through "current"
p->state == TASK_RUNNING is (AFAI understand) something different than the process that _is_ actually running at this very moment.
Quoted 1 line
since the
current->pidis only running
Usually yes. You probably mix 'running' up with "running in the sense of a user, not a kernel developer".
Quoted 8 lines
i want to develop a task manager for threads. the application reads properly the process information and the thread information but not able to refresh the thread information as i am building my own proc file where only threads are there
i am distinguishing between process and thread atfork.c
withclone_vmset..
A process is the set of all threads with the same
TGID (thread group identifier).
Quoted 2 lines
therefore i need to know which thread is currently running or not
task_t *current;
That one is running.
For SMP, you need a little different variables.
Quoted 3 lines
i want to distinguish between thread and process and after distinguishing between user thread and kernel thread
I think there are only kernel threads.
Quoted 6 lines
but i am unable to find any condition which will be true for kernel level thread during creation and false for user level thread
can you help me in this also
thanks
sounak
Jan Engelhardt
Quoted 6 lines · Jan Engelhardt
Quoted 3 lines
i want to distinguish between thread and process and after distinguishing between user thread and kernel thread
I think there are only kernel threads.
Um... what? I don't know about you but I run lots of multithreaded user space apps.
Lee