[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[linrad] Re: Error exit



Sorry, meant QT, not KDE.

One more observation. I tend to avoid mixing signal handlers 
and threads. There's basically nothing you need signals for 
that can't be handled within threads by the appropriate use 
of semaphores. You gain a lot in portability that way too.

Frank

leif@xxxxxxxxxx wrote:
> Hi Frank,
> 
> 
>>The proper way to shut them down is with pthread_cancel(), 
>>one for each thread.
> 
> Hmmm, this is what I do now - and find complicated during 
> the transition from a single thread to a multi-threaded
> structure.....
> 
> 
>>If you cancel a thread that has been started with default 
>>parameters, it will be cancelled either at a convenient 
>>point (such as when it attempts to acquire a mutex or 
>>semaphore) or at point of your own choosing, via 
>>pthread_testcancel().
> 
> Ok, what about threads waiting for keyboard, mouse events,
> network input or other I/O functions?
> I have set the parameters for CANCEL_ASYNCHRONOUS and
> put start and stop of hardware drivers in the main routine.
> Do you see any problem with that?
> 
> 
>>Usually the threads are started from a main routine, which 
>>proceeds to do a pthread_join() for each of the threads it's 
>>started. When threads are cancelled they exit cleanly to the 
>>corresponding pthread_join() points.
> 
> What about threads that do not exit explicitly, the ones
> killed by pthread_cancel() from the thread having the thread
> killing as its single task?
> It it safe to join only the thread that has killed all the others?
> There are many different modes of operation with different threads 
> running and it would be nice to not have to keep track of everything
> under error exit conditions;-)
> 
> Ctrl C is doing something, is it impossible to do the same from
> within an arbitrary thread within the program?
> 
> 
>>One thing this means is that there probably needs to be a 
>>single thread whose task is to shut down the other threads. 
>>It alone does a pthread_exit() which returns to a 
>>pthread_join() point.
> 
> What happens if I join threads that have already been killed?
> (In case it is unsafe to join only the "kill everything" thread?
> The code is intended to be portable to MS Windows and
> Macintosch...
> 
> 73
> 
> Leif / SM5BSZ
>  
> 
> 
> #############################################################
> This message is sent to you because you are subscribed to
>   the mailing list <linrad@xxxxxxxxxxxxxxxxxxxxx>.
> To unsubscribe, E-mail to: <linrad-off@xxxxxxxxxxxxxxxxxxxxx>
> To switch to the DIGEST mode, E-mail to <linrad-digest@xxxxxxxxxxxxxxxxxxxxx>
> To switch to the INDEX mode, E-mail to <linrad-index@xxxxxxxxxxxxxxxxxxxxx>
> Send administrative queries to  <linrad-request@xxxxxxxxxxxxxxxxxxxxx>
> 
> 
> 


#############################################################
This message is sent to you because you are subscribed to
  the mailing list <linrad@xxxxxxxxxxxxxxxxxxxxx>.
To unsubscribe, E-mail to: <linrad-off@xxxxxxxxxxxxxxxxxxxxx>
To switch to the DIGEST mode, E-mail to <linrad-digest@xxxxxxxxxxxxxxxxxxxxx>
To switch to the INDEX mode, E-mail to <linrad-index@xxxxxxxxxxxxxxxxxxxxx>
Send administrative queries to  <linrad-request@xxxxxxxxxxxxxxxxxxxxx>
LINRADDARNIL
d