4 ms·
cobegin/coend sound very much like co-routines, which is a relatively simple implementation of co-operative multitasking[1]. I've seen it used a lot in embedded
by spacedcowboy 6y ago
cobegin/coend sound very much like co-routines, which is a relatively simple implementation of co-operative multitasking[1]. I've seen it used a lot in embedded programming, and the original Mac OS (pre os-x) was co-operative. Not so common these days with linux/freeRTOS/others providing pre-emptive multitasking
As for 'monitor', that's a standard term for a high level synchronization concept - basically shared data between tasks, but you can only access that data via the monitor's procedures, and it enforces one-at-a-time access. You can create a monitor with a semaphore and a class-with-private-ivars, assuming all the accessors wait on the semaphore.
[1]: https://en.wikipedia.org/wiki/Coroutine https://en.wikipedia.org/wiki/Coroutine
- m463 6y agoI honestly have never done cooperative multitasking, but I think cobegin/coend were: cobegin stmt_a stmt_b stmt_c coend when the construct is entered a b and c were all executed in parallel. My thought was that a construct like that would be clumsy to do with library-based multitasking