From: Russ Cox <rsc@swtch.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] p9p threadpin() / threadunpin() ?
Date: Fri, 24 Jul 2009 17:13:39 -0700 [thread overview]
Message-ID: <dd6fe68a0907241713u54faafe5l1b57411523fc887@mail.gmail.com> (raw)
In-Reply-To: <f75780240907222104r374ae4f8of986c8f318d5533c@mail.gmail.com>
On Wed, Jul 22, 2009 at 9:04 PM, Venkatesh Srinivas<me@acm.jhu.edu> wrote:
> I noticed that p9p has threadpin() and threadunpin() in its thread
> library... they claim to make the current thread the only one runnable
> in this proc. I'm failing to see the purpose of these... a thread is
> not subject to preemptive scheduling, it can achieve the same effect
> by not calling yield(), right?
> Also, these two functions aren't in p9's libthread... is there any
> reason why not (assuming those two have a purpose)?
Yes and yes. Unfortunately, it is sometimes impossible to
avoid calling yield. On Plan 9, the graphics library uses
writes to /dev/draw and the kernel manages simultaneous
access by multiple threads. In Plan 9 port, everything
happens in user space and there are qlocks to help
make things thread safe. Unfortunately the fact that the
qlocks can reschedule inside a proc makes them different
from a write system call. Rather than rewrite all the draw
code to remove the assumption that /dev/draw writes do
not reschedule, I made the simulation of /dev/draw
also not reschedule. It is not a good approach in general,
which is why the functions are undocumented.
http://code.swtch.com/plan9port/src/tip/src/libdraw/drawclient.c#cl-189
Russ
prev parent reply other threads:[~2009-07-25 0:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-23 4:04 Venkatesh Srinivas
2009-07-25 0:13 ` Russ Cox [this message]
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=dd6fe68a0907241713u54faafe5l1b57411523fc887@mail.gmail.com \
--to=rsc@swtch.com \
--cc=9fans@9fans.net \
/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;
as well as URLs for NNTP newsgroup(s).