process.c File Reference

#include <stdio.h>
#include <string.h>
#include <os_config.h>
#include <sys/init.h>
#include <config/config_param.h>
#include <config/config_cparam.h>
#include <sys/arch.h>
#include <sys/ktypes.h>
#include <sys/ksched.h>
#include <sys/process.h>
#include <sys/mem.h>
#include <sys/queue.h>
#include <sys/ksemaphore.h>
#include <sys/msg.h>
#include <sys/shm.h>
#include <sys/decls.h>
#include <sys/stats.h>
#include <sys/timer.h>
#include <pthread.h>

Functions

void idle_task (void)
pid_t proc_create (unsigned int priority)
int process_invalidate (process_struct *proc)
int sys_process_status (pid_t pid, p_stat *ps)
pid_t sys_get_currentPID (void)
void process_block (queuep queue, unsigned int state)
void process_unblock (queuep queue)
reent_t * sys_get_reentrancy (void)

Variables

void * kernel_sp
 Process Table.
pid_t current_pid = -1
 Kernel Stack pointer.
pid_t prev_pid = -1
 Currently executing processes' ID.
process_structcurrent_process = NULL
 ID of process executing immediately before a context switch.

Detailed Description

This contains process management and thread management modules.

Function Documentation

void idle_task void   ) 
 

  • This task is run when the system is idle. This task is initialized during system init and is always run with the least priority.
    Returns:
  • Nothing
    Note:
  • None

pid_t proc_create unsigned int  priority  ) 
 

Process creation primitive.

  • Reserves a pid for the process.
  • Initializes the process structure (except for the context)
  • Places the process in the READY_Q.
    Parameters:
    priority is the priority of the process
    Returns:
  • PID of the new process.
  • -1 on Error. Max. process exceeded.
    Note:
  • None

void process_block queuep  queue,
unsigned int  state
 

Block the process.

  • Place the process into the specified wait queue, change the state of the process and set the kernel flag to PROCESS_BLOCK.
  • Call the process_scheduler
    Parameters:
    queue is the queue where the process is enqueued.
  • state is the state of the process in queue.
    Returns:
  • Nothing
    Note:
  • None

int process_invalidate process_struct proc  ) 
 

Remove the Process with pid. This is an internal proc that is called by sys_kill() and also by the schedulers to remove "DEAD" processes

Parameters:
proc is the process structure of process to invalidate
Returns:
  • 0 on Success
  • -1 on Error
Note:
  • None

void process_unblock queuep  queue  ) 
 

Unblock the first process in queue and place it onto the ready queue. Call the process_scheduler only if this is PRIO scheduling. This is because we do not want the current process to prematurely lose its time slice. Change the state of the process to PROC_READY

Parameters:
queue is the queue where the process is enqueued.
Returns:
  • Nothing
Note:
  • None

pid_t sys_get_currentPID void   ) 
 

Return the PID of the currently running process context

Returns:
  • PID of the currently running process context.
Note:
  • None

reent_t* sys_get_reentrancy void   ) 
 

Return the kernel re-entrancy structure. This structure holds program level state information for the current process. Upon each context switch this structure is updated. to minimize the run-time efficiency, each application ELF file can query a pointer to this structure once and then use it for all subsequent state information queries.

Parameters:
None 
Returns:
  • Pointer to kernel re-entrancy structure
Note:
  • None

int sys_process_status pid_t  pid,
p_stat ps
 

Return the status of the process.

Parameters:
pid is the Process ID of the process.
  • ps is the structure where the status is returned.
Returns:
  • The status of the process is returned on ps
  • If pid not an active process, ps->pid is assigned -1
Note:
  • None


Generated on Thu Feb 13 14:46:24 2014 for 2014.1_doc by  doxygen 1.4.5