Re: sched.c function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>So you want to say that only one task could be running
>at a single time 

per processor, yes.

>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!)

>is there any way without traversing the task list
>previously i thought of for_each_process(p)
>                        if(p->state==running)

Good idea.

>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.

>since the current->pid is only running

Usually yes. You probably mix 'running' up with "running in the sense of a 
user, not a kernel developer".

>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..

A process is the set of all threads with the same
TGID (thread group identifier).

>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.

>i want to distinguish between thread and process and
>after distinguishing between user thread and kernel
>thread 

I think there are only kernel threads.

>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
-- 
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux