Diffs on diffs :-)

Larry V. Streepy, Jr. (@healthcare.com)
Monday, October 07, 1996 02:03 PM PST

This is a multi-part message in MIME format.

--------------65BE18E23639BCDD7BE55F7F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Unfortunately, there are a couple of bugs in my pthread_cancel support (no, say it isn't so :-)

Oh well, I cam across a couple of cases that I missed in my testing last week. Here are the bugs:

1. If a thread calls pthread_testcancel during it's cleanup processing after being cancelled, the pthread kernel would hang.

2. I didn't realize that threads in PS_SLEEP_WAIT state are *NOT* on any queue, they are handled using a linked list. So, when cancelling a thread that was sleeping, a PANIC() I put in possiblymakeRunnable would go off.

Both of these are fixed. The diffs are attached.
--
Larry V. Streepy, Jr.
Chief Technical Officer, Healthcare Communications, Inc. mailto:@healthcare.com
(214) 851-7033 (Dallas Main #)
(970) 626-5028 (My office #) (970) 626-4425 (Fax)

--------------65BE18E23639BCDD7BE55F7F
Content-Type: text/plain; charset=us-ascii; name="cancel.diffs" Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="cancel.diffs"

Index: pthread_cancel.c
=================================================================== RCS file: /usr/cvssrc/pthreads-1_60_beta5/pthreads/pthread_cancel.c,v retrieving revision 1.1
diff -c -r1.1 pthread_cancel.c
*** pthread_cancel.c 1996/10/06 00:31:27 1.1
--- pthread_cancel.c 1996/10/07 18:33:27
***************
*** 187,192 ****
--- 187,197 ----
return; /* Can't be cancelled */
}

+ /* Ensure that we aren't in the process of exiting already */
+ if( TEST_PF_RUNNING_TO_CANCEL(pthread_run) ) {
+ return;
+ }
+
/* See if we have been cancelled */
if( TEST_PF_CANCELLED(pthread_run) ) {
/* Set this flag to avoid recursively calling pthread_exit */
***************
*** 266,277 ****
if( pthread->state == PS_RUNNING )
return; /* will happen at context switch */

! /* Otherwise, we need to take it off the queue and make it runnable */
! if( pthread->queue == NULL ) {
! PANIC(); /* Must be on a queue */
! }

- pthread_queue_remove(pthread->queue, pthread);
pthread_prio_queue_enq(pthread_current_prio_queue, pthread);
pthread->old_state = pthread->state;
pthread->state = PS_RUNNING;
--- 271,291 ----
if( pthread->state == PS_RUNNING )
return; /* will happen at context switch */

! /* If the thread is sleeping, the it isn't on a queue. */
! if( pthread->state == PS_SLEEP_WAIT ) {
! sleep_cancel( pthread ); /* Remove from sleep list */
! } else {
! /* Otherwise, we need to take it off the queue and make it runnable */
!
! if( pthread->queue == NULL ) {
! PANIC(); /* Must be on a queue */
! }
!
! pthread_queue_remove(pthread->queue, pthread);
! }
!
! /* And make it runnable */

pthread_prio_queue_enq(pthread_current_prio_queue, pthread);
pthread->old_state = pthread->state;
pthread->state = PS_RUNNING;


--------------65BE18E23639BCDD7BE55F7F--


Powered by FindMail Communications

Please email comments and suggestions to:comments@findmail.com
xmlarchive