puppy icon indicating copy to clipboard operation
puppy copied to clipboard

Waiting on a mutex/semaphore prevents process termination

Open egranata opened this issue 7 years ago • 0 comments

See 2eb9c88a544701cbbc0d1d823955addad409e107 for details:

If a process is killed while it's waiting on a mutex (or a semaphore for that matter...), the kernel moves the TSS information in order to execute the termination, but it leaves the process suspended so that it can be resumed when the synchronization object becomes available. This is done so that the object's queue does not end up containing stale process objects.

However, this means that a process could end up forever stuck waiting to collect a process that is waiting on a resource held, e.g. by a terminated process. While the process would never really get scheduled again, it would consume resources (e.g. memory, files, ...) that could not be freed without a reboot.

Fix options might include:

  • process objects are refcounted so process exit and memory deallocation are independent - the process would exit, but the process_t* would stick around for the process queue to notice it has terminated and move on from it
  • store the synchronization object a process is waiting on, and let that object's queue know that the process is going away on termination

egranata avatar Jun 20 '18 04:06 egranata