summaryrefslogtreecommitdiff
path: root/lib/libpthread/patches/p153
blob: 4e374e29a10756826c31aa51f973975bdae780ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<HEAD><TITLE>discuss@charon.mit.edu: [153] in "Pthreads Bugs"</TITLE>
<H1>[153] in Pthreads Bugs</H1></HEAD>
<A HREF="/"><IMG SRC="/i-d.gif" ALT="root"></A>
<A HREF="?153"><IMG SRC="/i-back.gif" ALT="meeting"></A>
<A HREF="/help.html"><IMG SRC="/i-help.gif" ALT="help"></A>
<A HREF="1"><IMG SRC="/i-first.gif" ALT="first"></A>
<A HREF="151"><IMG SRC="/i-fref.gif" ALT="first in chain"></A>
<A HREF="152"><IMG SRC="/i-pref.gif" ALT="previous in chain"></A>
<A HREF="152"><IMG SRC="/i-prev.gif" ALT="previous"></A>
<A HREF="154"><IMG SRC="/i-next.gif" ALT="next"></A>
<IMG SRC="/n-nref.gif" ALT="">
<IMG SRC="/n-lref.gif" ALT="">
<A HREF="161"><IMG SRC="/i-last.gif" ALT="last"></A>
<HR><H2>Re: sleep / SIGALRM problem in 1_60_beta6</H2>
<H3>daemon@ATHENA.MIT.EDU (Mon Dec  9 19:32:22 1996
)</H3>
<PRE>
Date: Mon, 09 Dec 1996 17:22:50 -0700
From: "Mark M. Evans" &lt;mevans@cti-ltd.com&gt;
To: Tim Hinderliter &lt;kyd@internap.com&gt;
Cc: pthreads-bugs@MIT.EDU

I think I found what caused fd_kern_wait() to block for the entire
hour (instead of waking up due to the SIGALRM).  Basically, the
SIGALRM that would move the sleeping thread to the run queue occurs
while pthread_kernel_lock is set, but *before* the critical section in
fd_kern_wait() that sets __fd_kern_wait_timeout.tv_sec to 3600.  So,
sig_handler_real() clears __fd_kern_wait_timeout.tv_sec "too soon."

I've worked around this by checking sig_to_process in the critical
section to determine if we are truly idle.  To do this I had to make
sig_to_process publicly available.

Here are the diffs (relative to the pthreads/pthreads directory):

diff -c -r1.2 -r1.3
*** signal.c	1996/11/20 05:09:50	1.2
--- signal.c	1996/12/09 23:14:52	1.3
***************
*** 65,71 ****
   */
  
  static sig_atomic_t signum_to_process[SIGMAX + 1] = { 0, };
! static sig_atomic_t sig_to_process = 0;
  
  /* static volatile	sigset_t sig_to_process; */
  static volatile	int	sig_count = 0;
--- 65,71 ----
   */
  
  static sig_atomic_t signum_to_process[SIGMAX + 1] = { 0, };
! sig_atomic_t sig_to_process = 0;
  
  /* static volatile	sigset_t sig_to_process; */
  static volatile	int	sig_count = 0;
*** fd_kern.c	1996/12/03 04:14:59	1.6
--- fd_kern.c	1996/12/09 23:14:51	1.7
***************
*** 215,221 ****
   * Called when there is no active thread to run.
   */
  extern struct timeval __fd_kern_wait_timeout;
! 
  void fd_kern_wait()
  {
  	fd_set fd_set_read, fd_set_write, fd_set_except;
--- 215,221 ----
   * Called when there is no active thread to run.
   */
  extern struct timeval __fd_kern_wait_timeout;
! extern volatile sig_atomic_t sig_to_process;
  void fd_kern_wait()
  {
  	fd_set fd_set_read, fd_set_write, fd_set_except;
***************
*** 254,260 ****
  
  		machdep_unset_thread_timer(NULL); 
  		__fd_kern_wait_timeout.tv_usec = 0;
! 		__fd_kern_wait_timeout.tv_sec = 3600;
  
  		machdep_sys_sigprocmask(SIG_UNBLOCK, &amp;sig_to_block, &amp;oset);
  
--- 254,260 ----
  
  		machdep_unset_thread_timer(NULL); 
  		__fd_kern_wait_timeout.tv_usec = 0;
! 		__fd_kern_wait_timeout.tv_sec = (sig_to_process) ? 0 : 3600;
  
  		machdep_sys_sigprocmask(SIG_UNBLOCK, &amp;sig_to_block, &amp;oset);