コード例 #1
0
/* Begin Function:_Sys_Load_Init **********************************************
Description : The loader of the "Init" process. The "Init" process is the first
              process in the system, and its priority is the highest at first.
              After it has done the process initialization task, its priority
              will be the lowest one.
Input       : None. 
Output      : None.
Return      : None.
******************************************************************************/
void _Sys_Load_Init(void)                                                  
{   
    /* Load it as a routine*/
    struct Proc_Init_Struct Process;

    Process.PID=0;
    Process.Name=(s8*)"Init";								                                 
    Process.Entrance=_Sys_Init;                                                             
    Process.Stack_Address=(ptr_int_t)Kernel_Stack;				                                          
    Process.Stack_Size=KERNEL_STACK_SIZE;
    Process.Max_Slices=4;                                                           
    Process.Min_Slices=1;                                                           
    Process.Cur_Slices=2;                                                                                                      
    Process.Priority=0;
    Process.Ready_Flag=READY;
    
    /* Load the init process */
    _Sys_Proc_Load(&Process); 

    /* Set the "Current_PID" and "Current_Prio" manually */
    Current_PID=0;
    Prio_List[0].Proc_Num=1;
    Current_Prio=PCB[0].Status.Priority;
         
    /* Set the left time of "Init" to 0 to trigger a normal context switch */
    PCB[0].Time.Lft_Tim=0; 
    
    /* Call the "Init" process function. Never returns.*/
    _Sys_Init();             
}
コード例 #2
0
/*Begin Function:_Sys_Start****************************************************
Description : The Function For Starting The Operating System.
Input       : Void.
Output      : Void.
******************************************************************************/
void _Sys_Start(void)
{
    Current_PID=0;
    PCB_PID_STATUS[0]|=INITED;                                                 //Set The "INITED" Flag.
    _Sys_Process_Initialization(Current_PID);                                  //The Current_PID Is 0 Here.We're Starting From The Init Process.
    SYS_LOAD_SP();                                                             //Load Its Stack Pointer.
    _Sys_Init();
}