| RTOS_MSPM0 1.1 ECE445M starter code

Data Structures | Macros | Typedefs | Functions
OS.h File Reference

Real Time Operating System for Labs 1, 2, 3, 4 and 5. More...

`#include <stdint.h>`

Go to the source code of this file.

## Data Structures
struct | Sema4
| Semaphore structure. Feel free to change the type of semaphore, there are lots of good solutions. More...
struct | Program

## Macros
#define | LAB1 0
| Set which lab is active so I can use the same OS.c for all Labs.
#define | LAB2 0
#define | LAB3 0
#define | LAB4 0
#define | LAB5 1
#define | LAB6 0
#define | TIME_1MS 80000
| Times assuming a 80 MHz.
#define | TIME_2MS (2*TIME_1MS)
#define | TIME_500US (TIME_1MS/2)
#define | TIME_250US (TIME_1MS/4)

## Typedefs
typedef struct Sema4 | Sema4_t
typedef struct Program | Program_t

## Functions
void | OS_Init (void)
| Initialize OS. More...
void | OS_InitSemaphore (Sema4_t *semaPt, int32_t value)
void | OS_Wait (Sema4_t *semaPt)
void | OS_Signal (Sema4_t *semaPt)
void | OS_bWait (Sema4_t *semaPt)
void | OS_bSignal (Sema4_t *semaPt)
int | OS_AddThread (void(*task)(void), uint32_t stackSize, uint32_t priority)
uint32_t | OS_Id (void)
int | OS_AddPeriodicThread (void(*task)(void), uint32_t period, uint32_t priority)
int | OS_AddS1Task (void(*task)(void), uint32_t priority)
int | OS_AddS2Task (void(*task)(void), uint32_t priority)
int | OS_AddPA28Task (void(*task)(void), uint32_t priority)
void | OS_Sleep (uint32_t sleepTime)
void | OS_Kill (void)
void | OS_Suspend (void)
uint32_t | OS_LockScheduler (void)
void | OS_UnLockScheduler (uint32_t previous)
void | OS_Fifo_Init (uint32_t size)
int | OS_Fifo_Put (uint32_t data)
uint32_t | OS_Fifo_Get (void)
int32_t | OS_Fifo_Size (void)
void | OS_MailBox_Init (void)
void | OS_MailBox_Send (uint32_t data)
uint32_t | OS_MailBox_Recv (void)
uint32_t | OS_Time (void)
uint32_t | OS_TimeDifference (uint32_t start, uint32_t stop)
void | OS_ClearMsTime (void)
uint32_t | OS_MsTime (void)
void | OS_Launch (uint32_t theTimeSlice)
int | OS_LoadProgram (char *name, uint32_t priority)

## Detailed Description

Real Time Operating System for Labs 1, 2, 3, 4 and 5.

ECE445M

Version
  V1.0

Author
  Valvano

Copyright
  Copyright 2026 by Jonathan W. Valvano, valva.nosp@m.no@m.nosp@m.ail.u.nosp@m.texa.nosp@m.s.edu,

Warning
  AS-IS

Note
  For more information see http://users.ece.utexas.edu/~valvano/

Date
  January 10, 2026

## Function Documentation

## ◆ OS_Init()

void OS_Init | ( | void |  | ) |

Initialize OS.

Initialize operating system, disable interrupts until OS_Launch. Initialize OS controlled I/O: serial, ADC, systick, LaunchPad I/O and timers. Interrupts not yet enabled.

Parameters

  none |

Returns
  none