From 7318b0704dfd30ad7910e170ca369688404c9b13 Mon Sep 17 00:00:00 2001 From: "W. Eric Norum" Date: Sat, 23 Mar 2002 21:42:36 +0000 Subject: [PATCH] Two small changes to allow operation on Darwin (Mac OS X): 1) Third argument to pthread_setcanceltype can't be NULL. 2) First argument to pthread_getschedparam must be valid thread id. Cosmetic changes to output of show command. --- src/libCom/osi/os/posix/osdThread.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/libCom/osi/os/posix/osdThread.c b/src/libCom/osi/os/posix/osdThread.c index e9765c7fc..f9f6dbf87 100644 --- a/src/libCom/osi/os/posix/osdThread.c +++ b/src/libCom/osi/os/posix/osdThread.c @@ -244,10 +244,11 @@ static void * start_routine(void *arg) { epicsThreadOSD *pthreadInfo = (epicsThreadOSD *)arg; int status; + int oldtype; status = pthread_setspecific(getpthreadInfo,arg); checkStatusQuit(status,"pthread_setspecific","start_routine"); - status = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,NULL); + status = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,&oldtype); checkStatusQuit(status,"pthread_setcanceltype","start_routine"); epicsMutexMustLock(listLock); ellAdd(&pthreadList,&pthreadInfo->node); @@ -513,17 +514,17 @@ void epicsThreadShow(epicsThreadId pthreadInfo,unsigned int level) { if(!epicsThreadInitCalled) epicsThreadInit(); if(!pthreadInfo) { - printf (" NAME ID OSIPRI OSSPRI STATE\n"); + printf (" NAME ID OSIPRI OSSPRI STATE\n"); } else { struct sched_param param; int policy; - int status; - int priority; + int priority = 0; - status = pthread_getschedparam(pthreadInfo->tid,&policy,¶m); - priority = (status ? 0 : param.sched_priority); - printf("%16.16s %p %d %8d %8.8s\n", pthreadInfo->name,(void *) + if ((pthreadInfo->tid != 0) + && (pthread_getschedparam(pthreadInfo->tid,&policy,¶m) == 0)) + priority = param.sched_priority; + printf("%16.16s %12p %3d%8d %8.8s\n", pthreadInfo->name,(void *) pthreadInfo,pthreadInfo->osiPriority,priority,pthreadInfo-> isSuspended?"SUSPEND":"OK"); if(level>0)