www.pudn.com > r&s1.10°æ±¾£«Îĵµ.rar > rsos.c


/* 
=============================================================================== 
| Copyright (C) 2004 RuanHaiShen, All rights reserved. 
| SUMMARY:  
|   r&s demo implementation. 
| 
| DESCRIPTION: 
|   See http://www.01s.org for documentation, latest information, license  
|   and contact details. 
|   email:ruanhaishen@01s.org 
=============================================================================*/  
/*===========================================================================*/ 
#include "inc/kapi.h" 
 
 
#define STACK_SIZE 512 
unsigned char stacks[3][STACK_SIZE]; 
 
void test_entry(arg_t arg); 
void test_welcome(arg_t arg); 
 
void main() 
{ 
    hardware_init(); 
    system_init(); 
 
    task_create(0, test_welcome, 0, "welcome", &stacks[0][STACK_SIZE-1], STACK_SIZE, 0);  
    task_create(1, test_entry, (arg_t)1, "TaskR", &stacks[1][STACK_SIZE-1], STACK_SIZE, 0); 
    task_create(2, test_entry, (arg_t)2, "TaskS", &stacks[2][STACK_SIZE-1], STACK_SIZE, 0); 
 
    system_start(); 
} 
 
void test_entry(arg_t arg) 
{ 
    int i; 
    int me; 
 
    task_sleep(500);        /*wait welcome completed */ 
     
    me = (int)arg; 
    for (;;) { 
        switch (me) { 
	    case 1: 
		    printk("R: She is quite a beauty!\n"); 
	        task_sleep(500); 
            for(i = 0; i < 50; i++){ 
                printk("."); 
                task_sleep(20); 
            } 
            halt();         /*shut down*/ 
		    break; 
	    case 2: 
	        task_sleep(300); 
		    printk("S: Yes, she is an angel.\n"); 
		    task_delete(SELF_PRIO); 
		    break; 
	    } 
    } 
} 
 
void test_welcome(arg_t arg) 
{ 
    int i; 
    arg = arg;          /* prevent compiler warning */ 
 
    printk("Initializing"); 
    for(i=0; i<30; i++){ 
        printk("."); 
        task_sleep(10); 
    } 
    printk("done!\n"); 
     
    task_sleep(100); 
 
    printk("R&S Real-Time Kernel V%d.%2.2d\n\n", system_version()/100, system_version()%100); 
} 
 
/*===========================================================================*/