9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] rwlocks on plan9
@ 2011-09-22 11:22 Steve Simon
  2011-09-22 11:42 ` Sape Mullender
  2011-09-22 11:46 ` Charles Forsyth
  0 siblings, 2 replies; 4+ messages in thread
From: Steve Simon @ 2011-09-22 11:22 UTC (permalink / raw)
  To: 9fans

Its quite possible that I'am doing somthing foolish,
but just in case its in the design...

It appears to me that when using rwlocks on plan9
I have to release the read lock before I can take the write lock
in a process - i.e. a single process cannot hold both.

This means that when updating a data structure I do this:

	rlock()
	search_structure()
	if(found){
		runlock()
		return
	}
	runlock()

	wlock()
	search_structure()	# search a seccond time
	if(found){			# lost the race
		wunlock()
		return
	}
	add_entry()			# won the race
	wlock()
	return

If I could hold both locks I wouldn't need to do the seccond
search.

is this how its susposed to work?

-Steve




^ permalink raw reply	[flat|nested] 4+ messages in thread
* Re: [9fans] rwlocks on plan9
@ 2011-09-22 19:33 Steve Simon
  0 siblings, 0 replies; 4+ messages in thread
From: Steve Simon @ 2011-09-22 19:33 UTC (permalink / raw)
  To: 9fans

Thanks to all who replied, I understand rwlocks
a little better now.

-Steve



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-22 19:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-22 11:22 [9fans] rwlocks on plan9 Steve Simon
2011-09-22 11:42 ` Sape Mullender
2011-09-22 11:46 ` Charles Forsyth
2011-09-22 19:33 Steve Simon

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).