This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Rework win32_wait to behave more like the UNIX waitpid()


The following changes are importants:

- It is possible to have multiple tasks waiting for a child process
  to terminate.

- When a child terminates, a single wait call will receive the
  corresponding process id.

- A call to wait will handle new incoming child processes.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-11-20  Pascal Obry  <obry@adacore.com>

	* initialize.c (ProcListCS): New extern variable (critical section).
	(ProcListEvt): New extern variable (handle).
	(__gnat_initialize)[Win32]: Initialize the ProcListCS critical
	section object and the ProcListEvt event.
	* final.c (__gnat_finalize)[Win32]: Properly finalize the
	ProcListCS critical section and the ProcListEvt event.
	* adaint.c (ProcListEvt): New Win32 event handle.
	(EnterCS): New routine to enter the critical section when dealing with
	child processes chain list.
	(LeaveCS): As above to exit from the critical section.
	(SignalListChanged): Routine to signal that the chain process list has
	been updated.
	(add_handle): Use EnterCS/LeaveCS, also call SignalListChanged when the
	handle has been added.
	(__gnat_win32_remove_handle): Use EnterCS/LeaveCS,
	also call SignalListChanged if the handle has been found and removed.
	(remove_handle): Routine removed, implementation merged with the above.
	(win32_wait): Use EnterCS/LeaveCS for the critical section. Properly
	copy the PID list locally to ensure that even if the list is updated
	the local copy remains valid. Add into the hl (handle list) the
	ProcListEvt handle. This handle is used to signal that a change has
	been made into the process chain list. This is to ensure that a waiting
	call can be resumed to take into account new processes. We also make
	sure that if the handle was not found into the list we start over
	the wait call. Indeed another concurrent call to win32_wait()
	could already have handled this process.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]