ShellContext=>OkToBlock

This commit is contained in:
Marty Kraimer
2004-07-09 17:53:54 +00:00
parent e9f54b70d9
commit f2fc8f8838
10 changed files with 140 additions and 46 deletions

View File

@@ -0,0 +1,60 @@
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* EPICS BASE Versions 3.13.7
* and higher are distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* epicsOkToBlockTest.cpp */
/* Author: Marty Kraimer Date: 09JUL2004*/
#include <stddef.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include "epicsThread.h"
typedef struct info {
int isOkToBlock;
}info;
extern "C" {
static void thread(void *arg)
{
info *pinfo = (info *)arg;
epicsThreadId idSelf = epicsThreadGetIdSelf();
int isOkToBlock;
printf("thread %s isOkToBlock %d\n",
epicsThreadGetNameSelf(),pinfo->isOkToBlock);
epicsThreadSetOkToBlock(idSelf,pinfo->isOkToBlock);
epicsThreadSleep(1.0);
isOkToBlock = epicsThreadIsOkToBlock(idSelf);
printf("thread %s epicsThreadIsOkToBlock %d\n",
epicsThreadGetNameSelf(),isOkToBlock);
epicsThreadSleep(.1);
free(pinfo);
}
void epicsOkToBlockTest(void)
{
unsigned int stackSize;
info *pinfo;
stackSize = epicsThreadGetStackSize(epicsThreadStackSmall);
pinfo = (info *)calloc(1,sizeof(info));
pinfo->isOkToBlock = 0;
epicsThreadCreate("threadA",50,stackSize,thread,pinfo);
pinfo = (info *)calloc(1,sizeof(info));
pinfo->isOkToBlock = 1;
epicsThreadCreate("threadB",50,stackSize,thread,pinfo);
epicsThreadSleep(2.0);
}
}