eventlab.c

来自「vxwork操作系统的相关内容」· C语言 代码 · 共 49 行

C
49
字号
/* eventLab.c - Server task for event lab */
/* Copyright Wind River Systems, Inc. */
/*
modification history
--------------------
01,30oct2002,fj   created
*/
#include "vxWorks.h"
#include "eventLib.h"
#include "stdio.h"
#include "taskLib.h"

int eventsRequested; /* argument used to spawn serverTask */


/* routine that prints a message to the console when it gets a specified event */
void serverTask (eventsRequested)
    {
    UINT32 *pEventsReceived = (UINT32 *)calloc (1,4);	/* allocate a buffer to store received events */
    int testEvent=0;

    /* print a message identifying the events that will be waited for */	
    printf("serverTask will now wait for Event(s): ");
	for(testEvent=0; testEvent<32; testEvent++)
            {
            if ((eventsRequested>>testEvent)&1)	/* was event (testEvent+1) requested? */
                printf(" %d  ", testEvent+1);	/* print a message to the console */
            }
        printf(".\n");

    FOREVER
        {
	/***************************************/
	/* insert an eventReceive( ) call here */
	/***************************************/
	eventReceive(eventsRequested,EVENTS_WAIT_ANY,WAIT_FOREVER,pEventsReceived);
        /* loop that prints message(s) identifying what events were received */		
        printf("Event(s) received: ");
	for(testEvent=0; testEvent<32; testEvent++)
            {
            if ((*pEventsReceived>>testEvent)&1)	/* was event (testEvent+1) received? */
                printf(" %d  ", testEvent+1);	/* print a message to the console */
            }
        printf(".  Waiting for next set of events.\n");
        }	
    }


⌨️ 快捷键说明

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