initialize.c, adaint.c: Use Lock_Task and Unlock_Task for non-blocking spawn.

2008-08-22  Pascal Obry  <obry@adacore.com>

	* initialize.c, adaint.c: Use Lock_Task and Unlock_Task for non-blocking
	spawn.

From-SVN: r139476
This commit is contained in:
Pascal Obry 2008-08-22 16:37:57 +02:00 committed by Arnaud Charlet
parent a3d4a22b01
commit af90c55af0
2 changed files with 30 additions and 34 deletions

View File

@ -2101,25 +2101,26 @@ __gnat_dup2 (int oldfd, int newfd)
/* Synchronization code, to be thread safe. */ /* Synchronization code, to be thread safe. */
static CRITICAL_SECTION plist_cs; #ifdef CERT
void /* For the Cert run times on native Windows we use dummy functions
__gnat_plist_init (void) for locking and unlocking tasks since we do not support multiple
{ threads on this configuration (Cert run time on native Windows). */
InitializeCriticalSection (&plist_cs);
}
static void void dummy (void) {}
plist_enter (void)
{
EnterCriticalSection (&plist_cs);
}
static void void (*Lock_Task) () = &dummy;
plist_leave (void) void (*Unlock_Task) () = &dummy;
{
LeaveCriticalSection (&plist_cs); #else
}
#define Lock_Task system__soft_links__lock_task
extern void (*Lock_Task) (void);
#define Unlock_Task system__soft_links__unlock_task
extern void (*Unlock_Task) (void);
#endif
typedef struct _process_list typedef struct _process_list
{ {
@ -2138,16 +2139,16 @@ add_handle (HANDLE h)
pl = (Process_List *) xmalloc (sizeof (Process_List)); pl = (Process_List *) xmalloc (sizeof (Process_List));
plist_enter();
/* -------------------- critical section -------------------- */ /* -------------------- critical section -------------------- */
(*Lock_Task) ();
pl->h = h; pl->h = h;
pl->next = PLIST; pl->next = PLIST;
PLIST = pl; PLIST = pl;
++plist_length; ++plist_length;
/* -------------------- critical section -------------------- */
plist_leave(); (*Unlock_Task) ();
/* -------------------- critical section -------------------- */
} }
static void static void
@ -2156,9 +2157,9 @@ remove_handle (HANDLE h)
Process_List *pl; Process_List *pl;
Process_List *prev = NULL; Process_List *prev = NULL;
plist_enter();
/* -------------------- critical section -------------------- */ /* -------------------- critical section -------------------- */
(*Lock_Task) ();
pl = PLIST; pl = PLIST;
while (pl) while (pl)
{ {
@ -2179,9 +2180,9 @@ remove_handle (HANDLE h)
} }
--plist_length; --plist_length;
/* -------------------- critical section -------------------- */
plist_leave(); (*Unlock_Task) ();
/* -------------------- critical section -------------------- */
} }
static int static int
@ -2275,11 +2276,12 @@ win32_wait (int *status)
} }
k = 0; k = 0;
plist_enter();
/* -------------------- critical section -------------------- */
(*Lock_Task) ();
hl_len = plist_length; hl_len = plist_length;
/* -------------------- critical section -------------------- */
hl = (HANDLE *) xmalloc (sizeof (HANDLE) * hl_len); hl = (HANDLE *) xmalloc (sizeof (HANDLE) * hl_len);
pl = PLIST; pl = PLIST;
@ -2288,9 +2290,9 @@ win32_wait (int *status)
hl[k++] = pl->h; hl[k++] = pl->h;
pl = pl->next; pl = pl->next;
} }
/* -------------------- critical section -------------------- */
plist_leave(); (*Unlock_Task) ();
/* -------------------- critical section -------------------- */
res = WaitForMultipleObjects (hl_len, hl, FALSE, INFINITE); res = WaitForMultipleObjects (hl_len, hl, FALSE, INFINITE);
h = hl[res - WAIT_OBJECT_0]; h = hl[res - WAIT_OBJECT_0];

View File

@ -76,12 +76,6 @@ __gnat_initialize (void *eh)
given that we have set Max_Digits etc with this in mind */ given that we have set Max_Digits etc with this in mind */
__gnat_init_float (); __gnat_init_float ();
#ifndef RTX
/* Initialize a lock for a process handle list - see adaint.c for the
implementation of __gnat_portable_no_block_spawn, __gnat_portable_wait */
__gnat_plist_init();
#endif
/* Note that we do not activate this for the compiler itself to avoid a /* Note that we do not activate this for the compiler itself to avoid a
bootstrap path problem. Older version of gnatbind will generate a call bootstrap path problem. Older version of gnatbind will generate a call
to __gnat_initialize() without argument. Therefore we cannot use eh in to __gnat_initialize() without argument. Therefore we cannot use eh in