mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Oeser <ioe-lkml@rameria.de>
To: linux-kernel@vger.kernel.org
Subject: [RFD] new syscalls: suspend_other/resume_other?
Date: Sun, 2 Sep 2007 17:04:21 +0200	[thread overview]
Message-ID: <200709021704.22325.ioe-lkml@rameria.de> (raw)

Hi there,

at the moment implementing a mark and sweep garbage collection 
subsystem is quite a hack, because you always have to use up
some signals for suspend/resume all threads to implement this.

For runtime environments (like D system libraries or JVMs) this is 
a hack, since you take away flexibility from the application.

A possible solution would be a syscall or a PTRACE extension
to realize the suspend/resume. I best describe the possible
syscall manpages here, so you get an idea.

NAME 
	suspend_other - suspends execution of all but the calling thread

SYNOPSIS
	long suspend_other(void);

RETURN VALUE
	Positive count suspended threads on success. 
        If 0, then suspend_other was a no-op and there is nothing to resume, but the
	call should still considered successful.
	If the number is -1, the errno has to be checked for possible error values.

ERRORS
	EDEADLK We run already a suspend_other() and the calling thread 
		has just been resumed.

	EPERM The calling thread is not allowed to do this. 
		(optional case due to security)
	
DESCRIPTION
	After sucessful return of this call, the affected process 
	is single threaded and only the calling thread runs 
	in this process (==MM struct).

	The thread, which calls this is responsible for resuming 
	all the suspended threads. One can iterate through 
	"/proc/self/task/", to verify for sure that one knows all threads,
	if the returned count doesn't match the expected value.

	Any per thread queued signals are deferred until resume_other()
	or process destruction.

NOTES
	This call might be restricted to the main thread.

------------

NAME 
	resume_other - resume execution of foreign thread in this process

SYNOPSIS
	long resume_other(pid_t tid)

RETURN VALUE
	Returns 0, if successful.
	Otherwise -1 is returned, the errno has to be checked for 
	possible error values and the call has no effect at all.

	Any non-blocked signals of that thread which happend during 
	suspend/resume are deliverd now.

ERRORS
	EINVAL The thread is running already. 
		(this is a severe caller BUG).
	ESRCH The thread with tid does not exist.
		(or doesn't belong to this process).
	EPERM The calling thread is not allowed to do this. 
		(optional case due to security)
	
DESCRIPTION
	After sucessful return of this call, the affected thread 
	is the the state it was before it was suspended 
	by calling suspend_other().

NOTES
	The value -1 for tid is reserved for future extension 
	(e.g. meaning ALL other threads).

	This call might be restricted to the main thread.

---------

Any opinions?


Best Regards

Ingo Oeser

             reply	other threads:[~2007-09-02 15:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-02 15:04 Ingo Oeser [this message]
2007-09-02 15:36 ` Alan Cox
2007-09-07 11:53 ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200709021704.22325.ioe-lkml@rameria.de \
    --to=ioe-lkml@rameria.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®