[Gary Shea <shea@xmission.com> writes:]
>Yeah, I really need it mapped. This is the user-level synchronization
>stuff we were talking about, a system call that takes a spinlock as an
>argument, puts the process to sleep, and releases the lock. To
>release the lock, it has to change the word holding the test-and-set
>bit.
Ah yes.
>My questions are: 1) Is the above the right way to test whether
>it's ok to write? and 2) How do I map the word into kernel space
>so I can change it? Can I figure it all out just looking at copyin/
>copyout? I looked at them and didn't see what I was looking for;
>I'll look again.
(1) is probably NOT ok. The problem is that another thread could come
along and unmap the memory. It would be a race condition.
(2) you can touch the memory by or'ing in 0x80000000 to the address, but you
have to use the probe support (see copyin/out) to protect against bogus
addresses (and even addresses which become bogus as you run). Ring 0 code
can generate references to ring 3 addresses because the kernel occupies the
low half of the 32-bit address space and user code occupies the top half.
User code *thinks* it starts at 0 because I put a 0x80000000 offset on all
user segments. But kernel code sees user addresses at their true linear
address. This is how copyin/out work.
I don't think it's worth it for you to add a mapping just to have a kernel
address for the user word. It's within your address space so doing it with
probes is probably more efficient.
Andy
Received on Mon Nov 7 08:13:52 1994
This archive was generated by hypermail 2.1.8 : Thu Sep 22 2005 - 15:12:10 PDT