Calculate your site FeedRank Today
FeedRank, a newly developed algorithm for ranking RSS feeds only on RSSMicro
Click here to learn more
 5/10 Good --- www.newsisfree.com http://feeds.feedburner.com/newsisfree/newscat141
| Search results for "" at newsisfree.com (powered by SIETS ... |
Saturday, May 03, 2008 --- 84 days ago http://feeds.feedburner.com/~r/newsisfree/newscat141/~3/282987546/
| [I just posted these questions to Apple’s darwin-userlevel mailing list, but they’re also worth cc:ing here as a follow-up to my last post.]
I’ve been experimenting this week with coroutines. Typically these are implemented as a type of cooperative thread, since each coroutine needs a separate stack and register set. I adapted Steve Dekorte’s libCoroutine, which basically just uses ucontext, with malloc’ed stacks.
It strikes me that ucontext is basically no lighter-weight than a pthread, in terms of address-space usage and context switch speed. Is that true? Or is there additional overhead to pthreads besides the stack + registers?
If so, then it might be simpler just to use pthreads, since the API is already in place, and existing system facilities (like ObjC and C++ exceptions, and Cocoa autorelease pools) already know how to work with them. But the cooperative scheduling of coroutines is a bonus in some ways, as it makes the flow of control more deterministic and reduces the need for complex locking and synchronization.
So my second question is whether there’s a clean way to implement cooperative scheduling of pthreads 1 , i.e. to have a set of threads that transfer control within themselves only via some sort of “yield” call, not by pre-emption? I’ve seen this implemented, for tutorial purposes, in Java using a shared lock. However, a coroutine transfers control to an explicitly-named other coroutine; it’ ... |
|
|
Recent Posts
|
|
|
Facebook
Del.icio.us
Digg
StumbleUpon
Reddit
Google