[Wylug-discuss] The talk on processes from last night....
Roger Leigh
rleigh at whinlatter.ukfsn.org
Fri Mar 17 16:53:12 GMT 2006
Rob Speed <wylug-discuss at robspeed.net> writes:
> uOn Wed, 15 Mar 2006, Roger Leigh wrote:
>>
>> See include/linux/init_task.h (INIT_TASK) for more details.
>> and arch/powerpc/kernel/init_task.c, for example usage.
>
> Naaap - can't find powerpc on my versions of t'kern (2.4.25, 2.6.9,
> 2.6.15).
It's in 2.6.16-rc6, which has ppc and powerpc arches. I'm not sure of
the difference.
> If you go by the i386 version, then init_task.c :=
> /*
> * Initial task structure.
> *
> * All other task structs will be allocated on slabs in fork.c
> */
> struct task_struct init_task = INIT_TASK(init_task);
>
> EXPORT_SYMBOL(init_task);
This is the key part. init_task is the head of the task table. Also
see init/main.c.
> doesn't appear to reference pid 0 being the kernel, similarly init_task.h
> doesn't either.
That's correct:
> /*
> * INIT_TASK is used to set up the first task table, touch at
> * your own risk!. Base=0, limit=0x1fffff (=2MB)
> */
> #define INIT_TASK(tsk) \
> { \
> .state = 0, \
> .thread_info = &init_thread_info, \
> .usage = ATOMIC_INIT(2), \
> .flags = 0, \
> .lock_depth = -1, \
> .prio = MAX_PRIO-20, \
> .static_prio = MAX_PRIO-20, \
> .policy = SCHED_NORMAL, \
> .cpus_allowed = CPU_MASK_ALL, \
> .mm = NULL, \
> .active_mm = &init_mm, \
> .run_list = LIST_HEAD_INIT(tsk.run_list), \
> .time_slice = HZ, \
> .tasks = LIST_HEAD_INIT(tsk.tasks), \
> .ptrace_children= LIST_HEAD_INIT(tsk.ptrace_children), \
> .ptrace_list = LIST_HEAD_INIT(tsk.ptrace_list), \
> .real_parent = &tsk, \
> .parent = &tsk, \
> .children = LIST_HEAD_INIT(tsk.children), \
> .sibling = LIST_HEAD_INIT(tsk.sibling), \
> .group_leader = &tsk, \
> .wait_chldexit = __WAIT_QUEUE_HEAD_INITIALIZER(tsk.wait_chldexit),\
> .real_timer = { \
> .function = it_real_fn \
> }, \
> .group_info = &init_groups, \
> .cap_effective = CAP_INIT_EFF_SET, \
> .cap_inheritable = CAP_INIT_INH_SET, \
> .cap_permitted = CAP_FULL_SET, \
> .keep_capabilities = 0, \
> .rlim = INIT_RLIMITS, \
> .user = INIT_USER, \
> .comm = "swapper", \
> .thread = INIT_THREAD, \
> .fs = &init_fs, \
> .files = &init_files, \
> .signal = &init_signals, \
> .sighand = &init_sighand, \
> .pending = { \
> .list = LIST_HEAD_INIT(tsk.pending.list), \
> .signal = {{0}}}, \
> .blocked = {{0}}, \
> .alloc_lock = SPIN_LOCK_UNLOCKED, \
> .proc_lock = SPIN_LOCK_UNLOCKED, \
> .switch_lock = SPIN_LOCK_UNLOCKED, \
> .journal_info = NULL, \
> }
pid is not mentioned in the initialiser list. It gets default
initialised to 0 (I think; see C99 §6.7.8 clause 10). See
include/linux/sched.h (struct task_struct; pid_t pid).
I don't know why it isn't initialised explicitly. I'm not a kernel
hacker, so I may well be talking rubbish!
Regards,
Roger
--
Roger Leigh
Printing on GNU/Linux? http://gutenprint.sourceforge.net/
Debian GNU/Linux http://www.debian.org/
GPG Public Key: 0x25BFB848. Please sign and encrypt your mail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: not available
Url : http://list.wylug.org.uk/pipermail/wylug-discuss/attachments/20060317/ae19bb18/attachment.bin
More information about the Wylug-discuss
mailing list