Re: how fork returns value

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

 



Thank you Rene,

On Tue, Oct 7, 2008 at 3:33 PM, Rene Herman <rene.herman@xxxxxxxxxxxx> wrote:
> On 07-10-08 06:02, Peter Teoh wrote:
>
>> 2.   lsmod will list all the modules loaded.   I printk() the "current",
>> and each running module have its own task struct ptr
>> value. But ps cannot see any of them.   But I supposed they should be
>> on the schedulable list of task-struct right?   Or may be not?
>
> Definitely not. Modules in Linux are not threads, either kernel- or
> fullblown. They are not scheduled but just sit around your RAM waiting to be
> called into exactly like other kernel code. They _are_ exactly like other
> kernel code once loaded.
>
> When you print current from a module you're printing the task_struct of
> whatever process is running inside that kernel code (at init time, the
> insmod process).
>

OK.   But if the module kthread_run() API is called, then it will be
running as  a "ps"-listable entity, right?

For example - I can list these:

/root/download/linux-2.6_latest/kernel>ps auxwf |grep kaud
root       899  0.0  0.0      0     0 ?        S<   15:13   0:00  \_ [kauditd]
root     31120  0.0  0.0   4120   676 pts/3    S+   23:50   0:00
\_ grep kaud

And inside kernel/audit.c:

audit.c:		kauditd_task = kthread_run(kauditd_thread, NULL, "kauditd");

So "kauditd" exists on the runqueue, and the task struct is kauditd_task.

So now question is - what is the value of "current" in these context
(inside the kauditd kernel thread), since all of them does not have a
initial userspace to map to?   Is "current" not kauditd_task as well?

Moreover, if I were to schedule a workqueue, in the current kernel
thread, and since workqueue is implemented on top of kernel thread
APIs, it will run with brand new taskstruct right (and thus new
"current")?

Sorry, I am confused.

In general, I am just trying to understand what are the entities that
can be schedule on the runqueue.

Thanks.

-- 
Regards,
Peter Teoh

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux