3 ms·
Either that, or only use co-operative (not pre-emptive) multitasking via coroutines. Specifying the points at which control is allowed to switch from one to ano
by silentbicycle 17y ago
Either that, or only use co-operative (not pre-emptive) multitasking via coroutines. Specifying the points at which control is allowed to switch from one to another is far easier than trying to reliably specify where it cannot and using locks.
Message-passing works quite well, but coroutines are also a viable option. The problems come from using pre-emptive threads AND shared state, because reasoning about who is modifying what (and at what stage of completion) becomes difficult. Co-routines avoid the former, message passing the latter. Which is simpler overall depends on the problem.
- uriel 17y ago> Message-passing works quite well, but coroutines are also a viable option. Why not both as in CSP/Limbo? ;) Edit: Note that you can get both in C too using the confusingly named libthread(2) http://man.cat-v.org/plan_9/2/thread http://man.cat-v.org/plan_9/2/thread (Also available in Unix as part of Plan 9 from User Space http://plan9.us http://plan9.us )
- silentbicycle 17y agoYou can do either in Lua pretty easily, too. Doing both doesn't make much sense, though - schlepping around large data structures in message-passing can be a performance problem, but unlike coroutines, can be very easily switched to a run over multiple machines. Coroutines are in the core language, and there's also ConcurrentLua (http://concurrentlua.luaforge.net/ http://concurrentlua.luaforge.net/) for message passing.
- uriel 17y ago> schlepping around large data structures in message-passing can be a performance problem, Not really, it is not too hard to implement it locally as passing pointers around.