📄 task_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 this copyright 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. |
* | |
* | The information in this software is subject to change without |
* | any prior notice and should not be construed as a commitment by |
* | TriMedia Technologies Inc. |
* | |
* | this code and information is provided "as is" without any |
* | warranty of any kind, either expressed or implied, including but |
* | not limited to the implied warranties of merchantability and/or |
* | fitness for any particular purpose. |
* +------------------------------------------------------------------+
*
* Module name : task_demo.c 1.5
*
* Last update : 17:07:24 - 00/06/16
*
* Description : Demo app which makes use of pSOS.
* Note that all the allocated pSOS
* resources have to be deallocated
* before exiting.
*
*/
#include "stdio.h"
#include "psos.h"
ULONG sem_enter;
ULONG sem_exit;
void
aaaa()
{
int err;
printf("aaaaaaa\n");
do {
err = sm_v(sem_enter);
err |= sm_p(sem_exit, SM_WAIT, 0);
printf("TOKEN SENT\n");
} while (!err);
printf("bbbbbbb\n");
t_delete(0L);
}
#define OTHER_TASK "othr"
main(int argc, char **argv)
{
int i;
ULONG task;
printf("Hello, world\n");
t_create(OTHER_TASK, 234, 10000, 10000, 0, &task );
sm_create("semp", 1, SM_PRIOR, &sem_enter);
sm_create("semv", 1, SM_PRIOR, &sem_exit);
sm_p(sem_exit, SM_WAIT, 0);
sm_p(sem_enter, SM_WAIT, 0);
t_start(task, T_PREEMPT | T_TSLICE | T_ASR | T_ISR, aaaa, 0);
for (i = 1; i < 10; i++) {
sm_p(sem_enter, SM_WAIT, 0);
sm_v(sem_exit);
printf("TOKEN RECEIVED\n");
}
sm_delete(sem_enter);
sm_delete(sem_exit);
while (t_ident(OTHER_TASK,0,&task) == 0) {
tm_wkafter(1);
}
printf("Goodbye, world\n");
return 308;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -