This program explains the basic step to signaling a semaphore in RTOS
#include "main.h"
#include <rtos.h> // add rtos header file here
#define TASK1 TCBP(1) /* task #1 */
#define TASK2 TCBP(2) /*task #2 */
#define TASK3 TCBP(3) /*task #3 */
#define priority 5 /* task priorities1*/
#define priority 10 /* task priorities 2*/
#define priority 2 /*task priorities3*/
#define semaphore OSECBP(1) /* binSem
#1 */
unsigned int counter;
void Task1( void )
{
while (1) {
{
OSSignalBinSem(semsphore);
}
task-switch();
}
}
void Task2( void )
{
while (1) {
OS_WaitBinSem(semaphore);
}
}
void Task3( void )
{
while (1) {
xxxxxxxxxxxx;
}
}
void main( void )
{
Init();
OSInit();
OSCreateTask(Task1,TCB,priority );
OSCreateTask(Task2,TCB,priority );
OSCreateTask(Task3,TCB,priority );
OSCreateBinSem(semaphore, 0);
counter = 0;
enable_interrupts();
while (1)
{
OSSched();
}
}
For more Application Program:CLICK HERE
#include "main.h"
#include <rtos.h> // add rtos header file here
#define TASK1 TCBP(1) /* task #1 */
#define TASK2 TCBP(2) /*task #2 */
#define TASK3 TCBP(3) /*task #3 */
#define priority 5 /* task priorities1*/
#define priority 10 /* task priorities 2*/
#define priority 2 /*task priorities3*/
#define semaphore OSECBP(1) /* binSem
#1 */
unsigned int counter;
void Task1( void )
{
while (1) {
{
OSSignalBinSem(semsphore);
}
task-switch();
}
}
void Task2( void )
{
while (1) {
OS_WaitBinSem(semaphore);
}
}
void Task3( void )
{
while (1) {
xxxxxxxxxxxx;
}
}
void main( void )
{
Init();
OSInit();
OSCreateTask(Task1,TCB,priority );
OSCreateTask(Task2,TCB,priority );
OSCreateTask(Task3,TCB,priority );
OSCreateBinSem(semaphore, 0);
counter = 0;
enable_interrupts();
while (1)
{
OSSched();
}
}
For more Application Program:CLICK HERE
No comments:
Post a Comment