mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-22 15:07:43 +08:00
* exceptions.cc (call_handler): Use new muto linked list to look for all
potential mutos owned by suspended thread. Clear waiting threads while thread is stopped. (proc_subproc): Clarify debugging output. * sync.h (class muto): Add 'next' field. (new_muto): Keep linked list alive.
This commit is contained in:
parent
4bc3b73cfd
commit
d3bda1df95
@ -1,3 +1,12 @@
|
|||||||
|
Thu Feb 24 14:45:06 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* exceptions.cc (call_handler): Use new muto linked list to look for
|
||||||
|
all potential mutos owned by suspended thread. Clear waiting threads
|
||||||
|
while thread is stopped.
|
||||||
|
(proc_subproc): Clarify debugging output.
|
||||||
|
* sync.h (class muto): Add 'next' field.
|
||||||
|
(new_muto): Keep linked list alive.
|
||||||
|
|
||||||
Thu Feb 24 00:59:15 2000 Christopher Faylor <cgf@cygnus.com>
|
Thu Feb 24 00:59:15 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
Fix final round of gcc warnings relating to unused parameters.
|
Fix final round of gcc warnings relating to unused parameters.
|
||||||
|
@ -713,7 +713,6 @@ call_handler (int sig, struct sigaction& siga, void *handler)
|
|||||||
CONTEXT *cx, orig;
|
CONTEXT *cx, orig;
|
||||||
int interrupted = 1;
|
int interrupted = 1;
|
||||||
int res;
|
int res;
|
||||||
extern muto *sync_proc_subproc;
|
|
||||||
|
|
||||||
if (hExeced != NULL && hExeced != INVALID_HANDLE_VALUE)
|
if (hExeced != NULL && hExeced != INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
@ -743,10 +742,13 @@ call_handler (int sig, struct sigaction& siga, void *handler)
|
|||||||
goto set_pending;
|
goto set_pending;
|
||||||
|
|
||||||
/* FIXME: Make multi-thread aware */
|
/* FIXME: Make multi-thread aware */
|
||||||
if (!sync_proc_subproc->unstable () && sync_proc_subproc->owner () != maintid &&
|
for (muto *m = muto_start.next; m != NULL; m = m->next)
|
||||||
!mask_sync->unstable () && mask_sync->owner () != maintid)
|
if (m->unstable () || m->owner () == maintid)
|
||||||
break;
|
goto keep_looping;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
keep_looping:
|
||||||
ResumeThread (hth);
|
ResumeThread (hth);
|
||||||
Sleep (0);
|
Sleep (0);
|
||||||
}
|
}
|
||||||
@ -781,12 +783,16 @@ call_handler (int sig, struct sigaction& siga, void *handler)
|
|||||||
interrupted = 0;
|
interrupted = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) ResumeThread (hth);
|
|
||||||
|
|
||||||
if (interrupted)
|
if (interrupted)
|
||||||
{
|
{
|
||||||
/* Clear any waiting threads prior to dispatching to handler function */
|
/* Clear any waiting threads prior to dispatching to handler function */
|
||||||
proc_subproc(PROC_CLEARWAIT, 1);
|
proc_subproc(PROC_CLEARWAIT, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
(void) ResumeThread (hth);
|
||||||
|
|
||||||
|
if (interrupted)
|
||||||
|
{
|
||||||
/* Apparently we have to set signal_arrived after resuming the thread or it
|
/* Apparently we have to set signal_arrived after resuming the thread or it
|
||||||
is possible that the event will be ignored. */
|
is possible that the event will be ignored. */
|
||||||
(void) SetEvent (signal_arrived); // For an EINTR case
|
(void) SetEvent (signal_arrived); // For an EINTR case
|
||||||
|
@ -333,7 +333,10 @@ proc_subproc (DWORD what, DWORD val)
|
|||||||
*/
|
*/
|
||||||
case PROC_CLEARWAIT:
|
case PROC_CLEARWAIT:
|
||||||
/* Clear all "wait"ing threads. */
|
/* Clear all "wait"ing threads. */
|
||||||
sip_printf ("clear waiting threads");
|
if (val)
|
||||||
|
sip_printf ("clear waiting threads");
|
||||||
|
else
|
||||||
|
sip_printf ("looking for processes to reap");
|
||||||
clearing = val;
|
clearing = val;
|
||||||
|
|
||||||
scan_wait:
|
scan_wait:
|
||||||
|
@ -21,8 +21,10 @@ details. */
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "winsup.h"
|
#include "winsup.h"
|
||||||
|
|
||||||
|
muto muto_start (0, 0);
|
||||||
|
|
||||||
/* Constructor */
|
/* Constructor */
|
||||||
muto::muto(int inh, const char *name) : sync (0), visits(0), waiters(-1), tid (0)
|
muto::muto(int inh, const char *name) : sync (0), visits(0), waiters(-1), tid (0), next (0)
|
||||||
{
|
{
|
||||||
/* Create event which is used in the fallback case when blocking is necessary */
|
/* Create event which is used in the fallback case when blocking is necessary */
|
||||||
if (!(bruteforce = CreateEvent (inh ? &sec_all_nih : &sec_none_nih, FALSE, FALSE, name)))
|
if (!(bruteforce = CreateEvent (inh ? &sec_all_nih : &sec_none_nih, FALSE, FALSE, name)))
|
||||||
|
@ -20,6 +20,7 @@ class muto
|
|||||||
HANDLE bruteforce; /* event handle used to control waiting for lock. */
|
HANDLE bruteforce; /* event handle used to control waiting for lock. */
|
||||||
DWORD tid; /* Thread Id of lock owner. */
|
DWORD tid; /* Thread Id of lock owner. */
|
||||||
public:
|
public:
|
||||||
|
class muto *next;
|
||||||
void *operator new (size_t, void *p) {return p;}
|
void *operator new (size_t, void *p) {return p;}
|
||||||
void *operator new (size_t) {return ::new muto; }
|
void *operator new (size_t) {return ::new muto; }
|
||||||
void operator delete (void *) {;} /* can't handle allocated mutos
|
void operator delete (void *) {;} /* can't handle allocated mutos
|
||||||
@ -27,7 +28,7 @@ public:
|
|||||||
|
|
||||||
/* This simple constructor is used for cases where no bruteforce
|
/* This simple constructor is used for cases where no bruteforce
|
||||||
event handling is required. */
|
event handling is required. */
|
||||||
muto(): sync(0), visits(0), waiters(-1), bruteforce(0), tid(0) {;}
|
muto(): sync(0), visits(0), waiters(-1), bruteforce(0), tid(0), next (0) {;}
|
||||||
/* A more complicated constructor. */
|
/* A more complicated constructor. */
|
||||||
muto(int inh, const char *name);
|
muto(int inh, const char *name);
|
||||||
~muto ();
|
~muto ();
|
||||||
@ -40,11 +41,14 @@ public:
|
|||||||
int unstable () {return !tid && (sync || waiters >= 0);}
|
int unstable () {return !tid && (sync || waiters >= 0);}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
extern muto muto_start;
|
||||||
|
|
||||||
/* Use a statically allocated buffer as the storage for a muto */
|
/* Use a statically allocated buffer as the storage for a muto */
|
||||||
#define new_muto(__inh, __name) \
|
#define new_muto(__inh, __name) \
|
||||||
({ \
|
({ \
|
||||||
static NO_COPY char __mbuf[sizeof(class muto) + 100] = {0}; \
|
static NO_COPY char __mbuf[sizeof(class muto) + 100] = {0}; \
|
||||||
muto *m; \
|
muto *m = muto_start.next; \
|
||||||
m = new (__mbuf) muto ((__inh), (__name)); \
|
muto_start.next = new (__mbuf) muto ((__inh), (__name)); \
|
||||||
m; \
|
muto_start.next->next = m; \
|
||||||
|
muto_start.next; \
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user