JAPAN RTOS TOPPERS/JSP kernel 1.4 PreRelease simulation environment JSP kernel Windows simulation

源代码在线查看: sample2.c

软件大小: 654 K
上传用户: fufuaihaitun
关键词: simulation kernel environment PreRelease
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*
				 *  TOPPERS/JSP Kernel
				 *      Toyohashi Open Platform for Embedded Real-Time Systems/
				 *      Just Standard Profile Kernel
				 * 
				 *  Copyright (C) 2000-2002 by Embedded and Real-Time Systems Laboratory
				 *                              Toyohashi Univ. of Technology, JAPAN
				 * 
				 *  忋婰挊嶌尃幰偼丆Free Software Foundation 偵傛偭偰岞昞偝傟偰偄傞 
				 *  GNU General Public License 偺 Version 2 偵婰弎偝傟偰偄傞忦審偐丆埲
				 *  壓偺(1)乣(4)偺忦審傪枮偨偡応崌偵尷傝丆杮僜僼僩僂僃傾乮杮僜僼僩僂僃
				 *  傾傪夵曄偟偨傕偺傪娷傓丏埲壓摨偠乯傪巊梡丒暋惢丒夵曄丒嵞攝晍乮埲壓丆
				 *  棙梡偲屇傇乯偡傞偙偲傪柍彏偱嫋戻偡傞丏
				 *  (1) 杮僜僼僩僂僃傾傪僜乕僗僐乕僪偺宍偱棙梡偡傞応崌偵偼丆忋婰偺挊嶌
				 *      尃昞帵丆偙偺棙梡忦審偍傛傃壓婰偺柍曐徹婯掕偑丆偦偺傑傑偺宍偱僜乕
				 *      僗僐乕僪拞偵娷傑傟偰偄傞偙偲丏
				 *  (2) 杮僜僼僩僂僃傾傪嵞棙梡壜擻側僶僀僫儕僐乕僪乮儕儘働乕僞僽儖僆僽
				 *      僕僃僋僩僼傽僀儖傗儔僀僽儔儕側偳乯偺宍偱棙梡偡傞応崌偵偼丆棙梡
				 *      偵敽偆僪僉儏儊儞僩乮棙梡幰儅僯儏傾儖側偳乯偵丆忋婰偺挊嶌尃昞帵丆
				 *      偙偺棙梡忦審偍傛傃壓婰偺柍曐徹婯掕傪宖嵹偡傞偙偲丏
				 *  (3) 杮僜僼僩僂僃傾傪嵞棙梡晄壜擻側僶僀僫儕僐乕僪偺宍傑偨偼婡婍偵慻
				 *      傒崬傫偩宍偱棙梡偡傞応崌偵偼丆師偺偄偢傟偐偺忦審傪枮偨偡偙偲丏
				 *    (a) 棙梡偵敽偆僪僉儏儊儞僩乮棙梡幰儅僯儏傾儖側偳乯偵丆忋婰偺挊嶌
				 *        尃昞帵丆偙偺棙梡忦審偍傛傃壓婰偺柍曐徹婯掕傪宖嵹偡傞偙偲丏
				 *    (b) 棙梡偺宍懺傪丆暿偵掕傔傞曽朄偵傛偭偰丆忋婰挊嶌尃幰偵曬崘偡傞
				 *        偙偲丏
				 *  (4) 杮僜僼僩僂僃傾偺棙梡偵傛傝捈愙揑傑偨偼娫愙揑偵惗偠傞偄偐側傞懝
				 *      奞偐傜傕丆忋婰挊嶌尃幰傪柶愑偡傞偙偲丏
				 * 
				 *  杮僜僼僩僂僃傾偼丆柍曐徹偱採嫙偝傟偰偄傞傕偺偱偁傞丏忋婰挊嶌尃幰偼丆
				 *  杮僜僼僩僂僃傾偵娭偟偰丆偦偺揔梡壜擻惈傕娷傔偰丆偄偐側傞曐徹傕峴傢
				 *  側偄丏傑偨丆杮僜僼僩僂僃傾偺棙梡偵傛傝捈愙揑傑偨偼娫愙揑偵惗偠偨偄
				 *  偐側傞懝奞偵娭偟偰傕丆偦偺愑擟傪晧傢側偄丏
				 * 
				 *  @(#) $Id: sample2.c,v 1.9 2003/06/30 14:19:18 takayuki Exp $
				 */
				
				
				/*
				 * TOPPERS/JSP 僒儞僾儖僾儘僌儔儉  - 5恖偺揘妛幰偵傛傞揘妛幰栤戣 -
				 *    僨僶僀僗僄儈儏儗乕僔儑儞 僨儌
				 *         Last update : 23rd, February, 2001
				 */
				
				#include 
				#include "kernel_id.h"
				#include "sample2.h"
				#include "device.h"
				#include "debugout.h"
				
				void task(VP_INT exinf)
				{
					ID tskid = (ID)exinf ;
				
					while(1==1)
					{
						set_flg(1,0x10 | (tskid-1));	/* 嬻暊 */
						if(pol_sem(tskid) == E_OK)
						{
							if(pol_sem( 1 + (tskid + 4 - 1) % 5 ) == E_OK)
							{
								set_flg(1,0x20 | (tskid-1));	/* 怘帠 */
								dly_tsk(1000 * tskid);
				
								set_flg(1,0x40 | (tskid-1));	/* 枮暊 */
								sig_sem( 1 + (tskid + 4 - 1) % 5 );
								sig_sem(tskid);
								dly_tsk(1000 * tskid);
								continue;
							}else
								sig_sem(tskid);
						}
						dly_tsk(1000 * tskid);
					}
				}
				
				void main_task(VP_INT exinf)
				{
					char patternchar[5] = {'.','-','O','.','z'};
					FLGPTN ptn;
					char buffer[6] = "-----";
				
				
					serial_ctl_por(TASK_PORTID, (IOCTL_CRLF | IOCTL_FCSND | IOCTL_FCRCV));
					syslog_1(LOG_NOTICE,"Sample task starts (exinf = %d)", exinf);
					
					act_tsk(1);
					act_tsk(2);
					act_tsk(3);
					act_tsk(4);
					act_tsk(5);
				
					do{
						wai_flg(1, 0xf0, TWF_ORW, &ptn);
						if((ptn & 0xf) >= 5)
							continue;
				
						OnDevice DeviceWrite(100,4,&ptn);
				
						if( buffer[ptn & 0xf] != patternchar[(ptn >> 4) & 0xf] )
						{
							buffer[ptn & 0xf] = patternchar[(ptn >> 4) & 0xf];
							syslog_5(LOG_NOTICE,"%c%c%c%c%c",buffer[0],buffer[1],buffer[2],buffer[3],buffer[4]);
							DebugOut(buffer);
							DebugOut("\n");
						}
					}while(1==1);
				}
							

相关资源