* [9fans] QLocks after fork
@ 2006-11-03 5:16 Joel Salomon
2006-11-03 7:14 ` Russ Cox
0 siblings, 1 reply; 3+ messages in thread
From: Joel Salomon @ 2006-11-03 5:16 UTC (permalink / raw)
To: 9fans
Is there some way, short of reinventing the wheel, to use QLocks to protect memory aquired by segattach(2) after a fork?
This came up when I was cribbing QLock code for user-level queued counting semaphores for homework; the professor wanted semaphores protecting a FIFO in a shared memory segment. I was reinventing the wheel anyway, so I included a sqlistinit() function that segattached an area for the wait queue—but is there a better solution? (Besides sharing all memory via rfork, I mean.)
--Joel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9fans] QLocks after fork
2006-11-03 5:16 [9fans] QLocks after fork Joel Salomon
@ 2006-11-03 7:14 ` Russ Cox
2006-11-03 14:50 ` Joel Salomon
0 siblings, 1 reply; 3+ messages in thread
From: Russ Cox @ 2006-11-03 7:14 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> Is there some way, short of reinventing the wheel,
> to use QLocks to protect memory aquired by segattach(2) after a fork?
I assume you mean that you segattach and then fork,
so that you have a segment shared between both
parent and child.
Probably the easiest thing to do in this case
would be to add a function that could register
a different region of memory to hold the QLp array
in qlock.c.
Russ
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [9fans] QLocks after fork
2006-11-03 7:14 ` Russ Cox
@ 2006-11-03 14:50 ` Joel Salomon
0 siblings, 0 replies; 3+ messages in thread
From: Joel Salomon @ 2006-11-03 14:50 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> I assume you mean that you segattach and then fork,
> so that you have a segment shared between both
> parent and child.
Yes, that's the homework assignment; seems a reasonable scenario.
> Probably the easiest thing to do in this case
> would be to add a function that could register
> a different region of memory to hold the QLp array
> in qlock.c.
Approximately what I'm doing for the semaphore code; the qlplistinit
(I called it sqlistinit before) function calls segattach itself—or
maybe a better method would be to take a pointer from the user? When
I get that working, I'll offer a patch for qlock.c.
(There's no particular general need for the Sem/sincr/sdecr/cansdecr
set, is there?)
--Joel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-11-03 14:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-11-03 5:16 [9fans] QLocks after fork Joel Salomon
2006-11-03 7:14 ` Russ Cox
2006-11-03 14:50 ` Joel Salomon
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).