BeRTOS
Functions | Variables
proc.c File Reference

Simple cooperative and preemptive multitasking scheduler. More...

#include "proc_p.h"
#include "proc.h"
#include "cfg/cfg_proc.h"
#include <cfg/log.h>
#include "cfg/cfg_monitor.h"
#include <cfg/macros.h>
#include <cfg/module.h>
#include <cfg/depend.h>
#include <cpu/irq.h>
#include <cpu/types.h>
#include <cpu/attr.h>
#include <cpu/frame.h>
#include <string.h>

Go to the source code of this file.

Functions

void proc_init (void)
 Initialize the process subsystem (kernel).
struct Process * proc_new_with_name (UNUSED_ARG(const char *, name), void(*entry)(void), iptr_t data, size_t stack_size, cpu_stack_t *stack_base)
 Create a new process, starting at the provided entry point.
const char * proc_name (struct Process *proc)
 Return the name of the specified process.
const char * proc_currentName (void)
 Return the name of the currently running process.
void proc_rename (struct Process *proc, const char *name)
 Rename a process.
void proc_setPri (struct Process *proc, int pri)
 Change the scheduling priority of a process.
void proc_entry (void)
 Entry point for all the processes.
void proc_exit (void)
 Terminate the current process.
static void proc_schedule (void)
 Call the scheduler and eventually replace the current running process.
bool proc_needPreempt (void)
 Check if we need to schedule another task.
void proc_preempt (void)
 Preempt the current task.
void proc_switch (void)
 Give the control of the CPU to another process.
void proc_wakeup (Process *proc)
 Immediately wakeup a process, dispatching it to the CPU.
void proc_yield (void)
 Voluntarily release the CPU.

Variables

REGISTER List proc_ready_list
 Track ready processes.
REGISTER Process * current_process
 Track running processes.
static struct Process main_process
 The main process (the one that executes main()).

Detailed Description

Simple cooperative and preemptive multitasking scheduler.

Author:
Bernie Innocenti <bernie@codewiz.org>
Stefano Fedrigo <aleph@develer.com>
Andrea Righi <arighi@develer.com>

Definition in file proc.c.


Function Documentation

struct Process* proc_new_with_name ( UNUSED_ARG(const char *, name)  ,
void(*)(void)  entry,
iptr_t  data,
size_t  stack_size,
cpu_stack_t *  stack_base 
) [read]

Create a new process, starting at the provided entry point.

Note:
The function
 proc_new(entry, data, stacksize, stack)
is a more convenient way to create a process, as you don't have to specify the name.
Returns:
Process structure of new created process if successful, NULL otherwise.

Definition at line 284 of file proc.c.

void proc_switch ( void  )

Give the control of the CPU to another process.

Note:
Assume the current process has been already added to a wait queue.
Warning:
This should be considered an internal kernel function, even if it is allowed, usage from application code is strongly discouraged.

Definition at line 604 of file proc.c.


Variable Documentation

REGISTER Process* current_process

Track running processes.

Definition at line 127 of file proc.c.

struct Process main_process [static]

The main process (the one that executes main()).

Definition at line 130 of file proc.c.

Track ready processes.

Access to this list must be performed with interrupts disabled

Definition at line 120 of file proc.c.