⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 root.c

📁 TM1300/PNX1300系列DSP(主要用于视频处理)操作系统pSOS系统的几个demo
💻 C
字号:
/*
 *  COPYRIGHT (c) 1995,2000 TriMedia Technologies Inc.
 *
 *   +-----------------------------------------------------------------+
 *   | THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY ONLY BE USED |
 *   | AND COPIED IN ACCORDANCE WITH THE TERMS AND CONDITIONS OF SUCH  |
 *   | A LICENSE AND WITH THE INCLUSION OF THE THIS COPY RIGHT NOTICE. |
 *   | THIS SOFTWARE OR ANY OTHER COPIES OF THIS SOFTWARE MAY NOT BE   |
 *   | PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER PERSON. THE   |
 *   | OWNERSHIP AND TITLE OF THIS SOFTWARE IS NOT TRANSFERRED.        |
 *   +-----------------------------------------------------------------+
 *
 *  Module name              : root.c    1.11
 *
 *  Module type              : IMPLEMENTATION
 *
 *  Title                    : 
 *
 *  Author                   : Juul van der Spek 
 *
 *  Last update              : 15:05:35 - 00/06/19
 *
 *  Reviewed                 : 
 *
 *  Revision history         : 
 *
 *  Description              :  
 *
 */

/*---------------------------- Includes --------------------------------------*/

#include "sys_conf.h"
#include <stdio.h>
#include <psos.h>
#include <probe.h>

/*---------------------------- Functions -------------------------------------*/



void idler()
{
    while(1) {
       printf("SYSTEM TICK\n");
       tm_wkafter(1);
    }
}

void idler2()
{
    while(1) {
       printf("......\n");
       tm_wkafter(2);
    }
}


volatile int time_left;
#define EVENT1 1
#define EVENT2 2

void real_idler()
{
    while (time_left);
    printf("*** BOEM ***\n");
    _psos_exit(0);
}


void time_bomb()
{
    unsigned long dummy;

    time_left = 10;

    tm_evevery( 5, EVENT1, &dummy );
    tm_evevery( 6, EVENT2, &dummy );

    while (time_left) {
        ev_receive( 
            EVENT1  | EVENT2,
            EV_WAIT | EV_ALL,
            0,
            &dummy
        );
         printf("*** TIME_BOMB TICK (%d)\n", time_left--);
    }
   t_suspend(0L);
}





/*
 * At initialistion, pSOS starts two tasks, the IDLE
 * task, which does nothing but spinning at the lowest
 * possible priority, and the ROOT task, which starts
 * executing at the highest possible priority with
 * a user provided function with prescribed name 'root'
 * Root should bring up your tasking systm.
 * NOTE that task functions in pSOS are not allowed 
 * to terminate other than with a t_suspend(0) or a
 * t_delete(0):
 */

void root(void)
{
   ULONG task1, task2, task3, task4;

   printf("Hello, world\n");

   t_create( "idler",  4,  10000,  10000,  0,  &task1 );
   t_start( task1, T_PREEMPT | T_TSLICE | T_ASR | T_ISR, idler,  0 );

   t_create( "idler2",  4,  10000,  10000,  0,  &task2 );
   t_start( task2, T_PREEMPT | T_TSLICE | T_ASR | T_ISR, idler2,  0 );

   t_create( "idler3",  8,  10000,  10000,  0,  &task3 );
   t_start( task3, T_PREEMPT | T_TSLICE | T_ASR | T_ISR, time_bomb,  0 );

   t_create( "real_idler",  3,  10000,  10000,  0,  &task4 );
   t_start( task4, T_PREEMPT | T_TSLICE | T_ASR | T_ISR, real_idler,  0 );

   printf("Goodbye, world\n");

   t_suspend(0L);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -