From: Tomas Hruby Date: Wed, 15 Sep 2010 14:09:43 +0000 (+0000) Subject: proc_init() X-Git-Tag: v3.2.0~868 X-Git-Url: http://zhaoyanbai.com/repos/icons/debian/static/datamaps.china.min.js?a=commitdiff_plain;h=2a2a19e542c7e1968e69939c7a413fd27cd344b7;p=minix.git proc_init() - code that initializes proc.c structures removed from main() and placed in proc_init() function --- diff --git a/kernel/main.c b/kernel/main.c index df88e040c..100609933 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -32,7 +32,6 @@ PUBLIC int main(void) /* Start the ball rolling. */ struct boot_image *ip; /* boot image pointer */ register struct proc *rp; /* process pointer */ - register struct priv *sp; /* privilege structure pointer */ register int i, j; int hdrindex; /* index to array of a.out headers */ phys_clicks text_base; @@ -46,26 +45,7 @@ PUBLIC int main(void) DEBUGEXTRA(("main()\n")); - /* Clear the process table. Anounce each slot as empty and set up mappings - * for proc_addr() and proc_nr() macros. Do the same for the table with - * privilege structures for the system processes. - */ - for (rp = BEG_PROC_ADDR, i = -NR_TASKS; rp < END_PROC_ADDR; ++rp, ++i) { - rp->p_rts_flags = RTS_SLOT_FREE; /* initialize free slot */ - rp->p_magic = PMAGIC; - rp->p_nr = i; /* proc number from ptr */ - rp->p_endpoint = _ENDPOINT(0, rp->p_nr); /* generation no. 0 */ - rp->p_scheduler = NULL; /* no user space scheduler */ - rp->p_priority = 0; /* no priority */ - rp->p_quantum_size_ms = 0; /* no quantum size */ - } - for (sp = BEG_PRIV_ADDR, i = 0; sp < END_PRIV_ADDR; ++sp, ++i) { - sp->s_proc_nr = NONE; /* initialize as free */ - sp->s_id = (sys_id_t) i; /* priv structure index */ - ppriv_addr[i] = sp; /* priv ptr from number */ - sp->s_sig_mgr = NONE; /* clear signal managers */ - sp->s_bak_sig_mgr = NONE; - } + proc_init(); /* Set up proc table entries for processes in boot image. The stacks of the * kernel tasks are initialized to an array in data space. The stacks diff --git a/kernel/proc.c b/kernel/proc.c index ecb12880d..8167bf458 100644 --- a/kernel/proc.c +++ b/kernel/proc.c @@ -79,6 +79,34 @@ FORWARD _PROTOTYPE( void enqueue_head, (struct proc *rp)); break; \ } +PUBLIC void proc_init(void) +{ + struct proc * rp; + struct priv *sp; + int i; + + /* Clear the process table. Anounce each slot as empty and set up + * mappings for proc_addr() and proc_nr() macros. Do the same for the + * table with privilege structures for the system processes. + */ + for (rp = BEG_PROC_ADDR, i = -NR_TASKS; rp < END_PROC_ADDR; ++rp, ++i) { + rp->p_rts_flags = RTS_SLOT_FREE;/* initialize free slot */ + rp->p_magic = PMAGIC; + rp->p_nr = i; /* proc number from ptr */ + rp->p_endpoint = _ENDPOINT(0, rp->p_nr); /* generation no. 0 */ + rp->p_scheduler = NULL; /* no user space scheduler */ + rp->p_priority = 0; /* no priority */ + rp->p_quantum_size_ms = 0; /* no quantum size */ + } + for (sp = BEG_PRIV_ADDR, i = 0; sp < END_PRIV_ADDR; ++sp, ++i) { + sp->s_proc_nr = NONE; /* initialize as free */ + sp->s_id = (sys_id_t) i; /* priv structure index */ + ppriv_addr[i] = sp; /* priv ptr from number */ + sp->s_sig_mgr = NONE; /* clear signal managers */ + sp->s_bak_sig_mgr = NONE; + } +} + /*===========================================================================* * idle * *===========================================================================*/ diff --git a/kernel/proto.h b/kernel/proto.h index fb84aa51c..bdc7a8a18 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -41,6 +41,7 @@ _PROTOTYPE( __dead void minix_shutdown, (struct timer *tp) ); /* proc.c */ _PROTOTYPE( int do_ipc, (reg_t r1, reg_t r2, reg_t r3) ); +_PROTOTYPE( void proc_init, (void) ); _PROTOTYPE( int mini_notify, (const struct proc *src, endpoint_t dst) ); _PROTOTYPE( void enqueue, (struct proc *rp) ); _PROTOTYPE( void dequeue, (const struct proc *rp) );