Main Page   Modules   Data Structures   File List   Globals  

task.h File Reference

Header file for task.c (Task management and control functions). More...

#include <avr/pgmspace.h>
#include "types.h"
#include "otos_cfg.h"
#include "message.h"
#include "hardware.h"
#include "mutex.h"

Go to the source code of this file.

Data Structures

struct  otos_task

Defines

#define OTOS_TASK_FUNCTION(pFunc, pArg)
#define SCHED_NORM   0
#define SCHED_BLOCK   1
#define otosInterruptReturn()   otosScheduler(SCHED_NORM)
 Return from Interrupt.

#define otosBlock()   otosScheduler(SCHED_BLOCK)
 Block task for ever.

#define DUMP_QUEUES   ((void) 0)

Typedefs

typedef otos_task OtosTask

Functions

OtosTask * otosCreateTask (void(*pFunc)(void *), void *pArg, uint8_t prio, uint16_t stacksize, uint8_t name)
 Create a task.

OtosTask * otosGetRunningTask (void)
 Get pointer to the running task.

uint8_t otosSetPriority (uint8_t prio)
 Set the priority of the running task.

void otosScheduler (uint8_t operation)
 Distribute CPU time.

void otosMain (void) __attribute__((noreturn))
uint8_t otosSetPreemtive (uint8_t timeSlice)
 Enable/disable preemtive multitasking.

uint8_t otosGetPreemtive (void)
 Get status of preemtive multitasking.


Detailed Description

Header file for task.c (Task management and control functions).

Definition in file task.h.


Define Documentation

#define OTOS_TASK_FUNCTION pFunc,
pArg   
 

Value:

void pFunc(void* pArg) __attribute__ ((noreturn)); \
void pFunc(void* pArg)

Definition at line 71 of file task.h.


Function Documentation

OtosTask* otosCreateTask void(*    pFunc)(void *),
void *    pArg,
uint8_t    prio,
uint16_t    stacksize,
uint8_t    name
 

Create a task.

If the created task has a priority higher than the running task, the new task is started immediately, else it is inserted in the ready queue.

Parameters:
pFunc Pointer to task function [void pFunc(void)]
pArg Arguments that are passed to the task function when it is started
prio Task priority [1..250]
stacksize Size of task's stack in bytes
name Task name (one character)
Returns:
Pointer to created task or NULL on error (out of memory)

Definition at line 113 of file task.c.

References otosAllocate(), otosInsertTaskInQueue(), and otosScheduler().

Referenced by main().

uint8_t otosGetPreemtive void    [inline]
 

Get status of preemtive multitasking.

Returns:
Status of preemptive multitasking \
  • 0: No preemtive multitasking
  • n: Use time slice of n timer ticks

Definition at line 560 of file task.c.

References g_timeSliceTicks.

OtosTask* otosGetRunningTask void    [inline]
 

Get pointer to the running task.

Returns:
Pointer to running task

Definition at line 190 of file task.c.

References g_pRunningTask.

void otosScheduler uint8_t    operation
 

Distribute CPU time.

Note:
Used internally by otOS, not intended to be called by otOS applications.
Parameters:
operation 
  • SCHED_BLOCK: Block running task
  • SCHED_NORM: Normal task switch

Definition at line 368 of file task.c.

References g_performDispatch, g_pReadyQueue, g_pRunningTask, otosDispatch(), otosError(), otosGetTickDiff(), otosGetTicks(), and otosInsertTaskInQueue().

Referenced by OTOS_TASK_FUNCTION(), otosCreateTask(), otosSendEvent(), otosSendMessage(), otosSetPriority(), otosSleep(), otosUnlockMutex(), and SIGNAL().

uint8_t otosSetPreemtive uint8_t    timeSlice
 

Enable/disable preemtive multitasking.

Parameters:
timeSlice: 
  • 0: No preemtive multitasking
  • n: Use time slice of n timer ticks
Returns:
Old setting

Definition at line 533 of file task.c.

References g_timeSliceCounter, and g_timeSliceTicks.

uint8_t otosSetPriority uint8_t    prio
 

Set the priority of the running task.

Parameters:
prio New priority
Returns:
The old priority of the running task

Definition at line 204 of file task.c.

References g_pRunningTask, and otosScheduler().


Generated on Sat Jan 25 18:41:43 2003 for otOS by doxygen1.3-rc2