Piccolo OS Plus 1.01
A feature rich extension of Piccolo OS
Data Structures | Macros | Enumerations | Variables
C:/Users/Keith/source/repos/piccolo_os_plus/piccolo_os.h File Reference

Piccolo OS Plus. More...

Go to the source code of this file.

Data Structures

struct  piccolo_os_task_t
 Piccolo OS task data structure. More...
 
struct  piccolo_os_internals_t
 Piccolo OS internal data structure. More...
 

Macros

#define PICCOLO_OS_STACK_SIZE   1024
 Size of a task stack in 32 bit words. More...
 
#define PICCOLO_OS_THREAD_PSP   0xFFFFFFFD
 
#define PICCOLO_OS_TIME_SLICE   1000
 The OS time slice, in microseconds. More...
 
#define PICCOLO_OS_MAX_IDLE   700
 The maximum time that the scheduler will sleep in the idle task (in usec). More...
 
#define PICCOLO_OS_NO_IDLE_FOR_SIGNALS   true
 If true, the scheduler will not idle (sleep) if tasks are blocking for signals. More...
 
#define PICCOLO_OS_MULTICORE   true
 Enable/disable multi-core scheduling. More...
 
#define PICCOLO_OS_MAX_SIGNAL   10
 Signal channel size. (max is INT32_MAX) More...
 
#define PICCOLO_SPIN_LOCK_ID   PICO_SPINLOCK_ID_OS1
 

Enumerations

enum  piccolo_task_flag_values {
  PICCOLO_TASK_RUNNING = 0x1 , PICCOLO_TASK_ZOMBIE = 0x2 , PICCOLO_TASK_SLEEPING = 0x4 , PICCOLO_TASK_GET_SIGNAL_BLOCKED = 0x8 ,
  PICCOLO_TASK_SEND_SIGNAL_BLOCKED = 0x10 , PICCOLO_TASK_BLOCKING = (PICCOLO_TASK_SLEEPING | PICCOLO_TASK_GET_SIGNAL_BLOCKED | PICCOLO_TASK_SEND_SIGNAL_BLOCKED)
}
 

Functions

The initializers

These are literally the beginning and the end.

piccolo_init() is called before any other Piccolo function. piccolo_start() begins the piccolo scheduler execution, and never returns.

void piccolo_init ()
 Initialize the piccolo run time environment. More...
 
void piccolo_start ()
 Start the Piccolo Task scheduler. More...
 
Task creation and execution control

These are the functions for creating and ending tasks, and controlling their execution. Once a task is running, it can yield the processor to the next task voluntarily. It can also suspend execution (sleep) for a time and allow other tasks to execute.

Note
To send a signal to a task, the sender must have the pointer to the task returned by piccolo_create_task().
piccolo_os_task_tpiccolo_create_task (void(*pointer_to_task_function)(void))
 Create a new task and initialize its stack. More...
 
void piccolo_end_task ()
 Ends the current task, never returns. More...
 
static void piccolo_yield (void)
 Yields the processor to another task. More...
 
void piccolo_syscall (void)
 Same as piccolo_yield. More...
 
void piccolo_sleep (uint32_t sleep_time_ms)
 sleeps for a specified number of milliseconds More...
 
void piccolo_sleep_until (absolute_time_t until)
 sleeps until an absolute time. More...
 
Task Signals

Each task has a built in signal channel which can be used for inter-task synchronization. A channel can hold a specified number of signals. (The maximum is a #define value which can be as large as 2^31). Signals are only events which contain no data and do not occupy any memory. Signals can be sent to a task by another task, or by interrupt service handlers or timer or alarm callback routines. (Though only tasks ought to try blocking!)

piccolo_os_task_tpiccolo_get_task_id ()
 Get the ID (task struct address) of the running task. More...
 
int32_t piccolo_send_signal (piccolo_os_task_t *toTask)
 Send a signal to the specified task. More...
 
int32_t piccolo_send_signal_blocking (piccolo_os_task_t *toTask)
 Send a signal to the specified task. If the signal channel is full, block until it is not. More...
 
int32_t piccolo_send_signal_blocking_timeout (piccolo_os_task_t *toTask, uint32_t timeout_ms)
 Send a signal to a specified task. If the channel is full, block with a timeout until it is not. More...
 
int32_t piccolo_get_signal ()
 Attempt to get a signal. More...
 
int32_t piccolo_get_signal_blocking ()
 Get a signal. If none are available, block until one arrives. More...
 
int32_t piccolo_get_signal_blocking_timeout (uint32_t timeout_ms)
 Attempt to get a signal. If none are available, block with a timeout until one arrives. More...
 
int32_t piccolo_get_signal_all ()
 Get all the signals available. More...
 
int32_t piccolo_get_signal_all_blocking ()
 Get all the signals available. If none are available, block until one arrives. More...
 
int32_t piccolo_get_signal_all_blocking_timeout (uint32_t timeout_ms)
 Get all the signals available. If none are available, block with a timeout until one arrives. More...
 

Variables

**struct piccolo_os_task_t piccolo_os_task_t
 

Detailed Description

Piccolo OS Plus.

Author
Keith Standiford
Version
1.01
Date
2022-08-15

Portions copyright (C) 2021 Gary Sims Portions copyright (C) 2017 Scott Nelson Portions copyright (C) 2015-2018 National Cheng Kung University, Taiwan Portions copyright (C) 2014-2017 Chris Stones

SPDX-License-Identifier: BSD-3-Clause

Piccolo OS is a simple cooperative multi-tasking OS originally written by Gary Sims as a teaching tool.