Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 2 Oct 2007 18:52:31 -0700
From:      Alfred Perlstein <alfred@freebsd.org>
To:        hackers@freebsd.org
Subject:   Critical Sections for userland.
Message-ID:  <20071003015231.GJ31826@elvis.mu.org>

next in thread | raw e-mail | index | archive | help
Hi guys, we need critical sections for userland here.

This is basically to avoid a process being switched out while holding
a user level spinlock.

The way I envisioned doing this was as follows:

1) syscall that sets a pointer in the struct thread.
2) user mlocks that page.
3) when scheduler goes to switch out a process due to quantum it checks
   this pointer, if set it will give the process more time to run and
   not switch it out. (*)
4) the load would seem to have to be non-faulting.

So my questions are:

1) Where would be a good place to add this code in the scheduler and how?
2) How does one do a read/write to userland address, but if the access would
fault, then return an error rather than trap?  I'm quite sure the scheduling
decisions would be made inside of the timer interrupt, (am I right?), and
hence would not be allowed to fault in pages. 

(*) Note, we will implement limits to this so that a haywire application
    is not able to be "critical" forever.

Any help would be appreciated.

-- 
- Alfred Perlstein



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071003015231.GJ31826>