/* there are threads in plan 9 */
#include <u.h>
#include <libc.h>
#include <thread.h>
int killme = 0, i = 0, x = 0;
void thread_task(void *data)
{
i++;
if (i > 2000) {
x++;
killme = x > 200;
}
}
/* threadmain() instead of main() - requires argc, argv */
void threadmain(int argc, char *argv[]) /* must use *argv[] - not
**argv or argv[][] */
{
int tid;
tid = threadcreate(thread_task, 0, 2048); /* (function,
argument, stack size) */
if (tid < 0)
sysfatal("could not create thread");
while (!killme) {
print(1, "waiting\n");
sleep(2000); /* wait two seconds */
}
threadexitsall(0); /* use instead of exits() - with all suffix,
terminates all threads */
}
On Oct 25, 2007, at 4:51 PM, erik quanstrom wrote:
So, those with experience with threading implementations on weird
real-time or embedded operating systems:
Have you ever ran into a thread implementation where two threads
could *not* directly access each other's .bss (or equiv)/heap?
i.e. have you ever encountered a scenario where sibling threads
actually had completely separate sets of page tables?
under plan 9, don't we call those processes?
that doesn't sound like any imbedded environment i've worked in.
it's getting mighty fancy to have one set of pagetables. ;-)
- erik