Roomba Tank
CSC 460 Project 3
Data Structures | Macros | Typedefs | Enumerations | Functions
os.h File Reference

Go to the source code of this file.

Data Structures

struct  Mutex
 
struct  Event
 
struct  ProcessDescriptor
 

Macros

#define MAXTHREAD   16
 
#define WORKSPACE   256 /** in bytes, per THREAD */
 
#define MAXMUTEX   8
 
#define MAXEVENT   8
 
#define MSECPERTICK   10 /** resolution of a system tick in milliseconds */
 
#define MINPRIORITY   10 /** 0 is the highest priority, 10 the lowest */
 
#define NULL   0 /** undefined */
 
#define Disable_Interrupt()    asm volatile ("cli"::)
 
#define Enable_Interrupt()    asm volatile ("sei"::)
 

Typedefs

typedef void(* voidfuncptr) (void)
 
typedef unsigned int PID
 
typedef unsigned int MUTEX
 
typedef unsigned int PRIORITY
 
typedef unsigned int EVENT
 
typedef unsigned int TICK
 
typedef enum process_states PROCESS_STATES
 
typedef enum kernel_request_type KERNEL_REQUEST_TYPE
 
typedef enum mutex_state MUTEX_STATE
 
typedef struct Mutex MTX
 
typedef enum event_state EVENT_STATE
 
typedef struct Event EVT
 
typedef struct ProcessDescriptor PD
 

Enumerations

enum  process_states {
  DEAD = 0, READY, RUNNING, SLEEPING,
  BLOCKED_ON_MUTEX, WAITING_ON_EVENT, TERMINATED
}
 
enum  kernel_request_type {
  NONE = 0, CREATE, NEXT, SLEEP,
  TERMINATE, SUSPEND, RESUME, MUTEX_INIT,
  MUTEX_LOCK, MUTEX_UNLOCK, EVENT_INIT, EVENT_WAIT,
  EVENT_SIGNAL
}
 
enum  mutex_state { DISABLED, FREE, LOCKED }
 
enum  event_state { INACTIVE, UNSIGNALLED, SIGNALLED }
 

Functions

void OS_Abort (void)
 
PID Task_Create (void(*f)(void), PRIORITY py, int arg)
 
void Task_Terminate (void)
 
void Task_Next (void)
 
int Task_GetArg (PID p)
 
void Task_Suspend (PID p)
 
void Task_Resume (PID p)
 
void Task_Sleep (TICK t)
 
MUTEX Mutex_Init (void)
 
void Mutex_Lock (MUTEX m)
 
void Mutex_Unlock (MUTEX m)
 
EVENT Event_Init (void)
 
void Event_Wait (EVENT e)
 
void Event_Signal (EVENT e)
 

Macro Definition Documentation

#define Disable_Interrupt ( )    asm volatile ("cli"::)

Definition at line 16 of file os.h.

#define Enable_Interrupt ( )    asm volatile ("sei"::)

Definition at line 17 of file os.h.

#define MAXEVENT   8

Definition at line 7 of file os.h.

#define MAXMUTEX   8

Definition at line 6 of file os.h.

#define MAXTHREAD   16

Definition at line 4 of file os.h.

#define MINPRIORITY   10 /** 0 is the highest priority, 10 the lowest */

Definition at line 9 of file os.h.

#define MSECPERTICK   10 /** resolution of a system tick in milliseconds */

Definition at line 8 of file os.h.

#define NULL   0 /** undefined */

Definition at line 13 of file os.h.

#define WORKSPACE   256 /** in bytes, per THREAD */

Definition at line 5 of file os.h.

Typedef Documentation

typedef unsigned int EVENT

Definition at line 24 of file os.h.

typedef enum event_state EVENT_STATE

This is the set of states that a mutex can be in at any given time.

typedef struct Event EVT

Each event is represented by a event struct, which contains all relevant information about this event.

This is the set of kernel requests

typedef struct Mutex MTX

Each mutex is represented by a mutex struct, which contains all relevant information about this mutex.

typedef unsigned int MUTEX

always non-zero if it is valid

Definition at line 22 of file os.h.

typedef enum mutex_state MUTEX_STATE

This is the set of states that a mutex can be in at any given time.

typedef struct ProcessDescriptor PD

Each task is represented by a process descriptor, which contains all relevant information about this task. For convenience, we also store the task's stack, i.e., its workspace, in here.

typedef unsigned int PID

pointer to void f(void)

Definition at line 21 of file os.h.

typedef unsigned int PRIORITY

always non-zero if it is valid

Definition at line 23 of file os.h.

This is the set of states that a task can be in at any given time.

typedef unsigned int TICK

always non-zero if it is valid

Definition at line 25 of file os.h.

typedef void(* voidfuncptr) (void)

Definition at line 19 of file os.h.

Enumeration Type Documentation

This is the set of states that a mutex can be in at any given time.

Enumerator
INACTIVE 
UNSIGNALLED 
SIGNALLED 

Definition at line 82 of file os.h.

This is the set of kernel requests

Enumerator
NONE 
CREATE 
NEXT 
SLEEP 
TERMINATE 
SUSPEND 
RESUME 
MUTEX_INIT 
MUTEX_LOCK 
MUTEX_UNLOCK 
EVENT_INIT 
EVENT_WAIT 
EVENT_SIGNAL 

Definition at line 43 of file os.h.

This is the set of states that a mutex can be in at any given time.

Enumerator
DISABLED 
FREE 
LOCKED 

Definition at line 62 of file os.h.

This is the set of states that a task can be in at any given time.

Enumerator
DEAD 
READY 
RUNNING 
SLEEPING 
BLOCKED_ON_MUTEX 
WAITING_ON_EVENT 
TERMINATED 

Definition at line 30 of file os.h.

Function Documentation

EVENT Event_Init ( void  )

Application level event init to setup system call

Definition at line 711 of file os.c.

void Event_Signal ( EVENT  e)

Application level event signal to setup system call

Definition at line 735 of file os.c.

void Event_Wait ( EVENT  e)

Application level event wait to setup system call

Definition at line 723 of file os.c.

MUTEX Mutex_Init ( void  )

Application level mutex init to setup system call

Definition at line 674 of file os.c.

void Mutex_Lock ( MUTEX  m)

Application level mutex lock to setup system call

Definition at line 686 of file os.c.

void Mutex_Unlock ( MUTEX  m)

Application level mutex unlock to setup system call

Definition at line 699 of file os.c.

void OS_Abort ( void  )

Just quits

Definition at line 667 of file os.c.

PID Task_Create ( voidfuncptr  f,
PRIORITY  py,
int  arg 
)

Application or kernel level task create to setup system call

Definition at line 747 of file os.c.

int Task_GetArg ( PID  p)

Application level task getarg to return intiial arg value

Definition at line 829 of file os.c.

void Task_Next ( void  )

Application level task next to setup system call to give up CPU

Definition at line 768 of file os.c.

void Task_Resume ( PID  p)

Application level task resume to setup system call

Definition at line 805 of file os.c.

void Task_Sleep ( TICK  t)

Application level task sleep to setup system call

Definition at line 779 of file os.c.

void Task_Suspend ( PID  p)

Application level task suspend to setup system call

Definition at line 793 of file os.c.

void Task_Terminate ( void  )

Prototypes

Application level task terminate to setup system call

Definition at line 817 of file os.c.