by mitghi on 1/12/16, 12:50 PM with 24 comments
by david-given on 1/13/16, 7:36 PM
Non-preemptive multitasking made reasoning about the problem way easier, because I had no concurrency to worry about, while still allowing inversion of control flow which meant that the SMTP state machines were small and simple. It worked really well.
...until I started getting bug reports from users about weird irreproducable crashes. After a very, very long time I eventually figured out that if spey was built on a system where sqlite had been compiled with pthread support, then it automatically linked in a thread-safe malloc, which tried to fetch the current thread ID, which on some versions of pthreads on some Linux architectures on some glibc versions with some kernel versions, was stored at the top of the stack. It used alignment tricks to find this.
So, every time something called malloc(), the libc was doing the equivalent of:
threadid = *(int*) (alignup(sp, 16MB) - sizeof(int))
Except my stacks weren't allocated through pthreads, so threadid ended up being garbage. Hilarity ensued.I eventually rebuild the coroutine library to be a wrapper around pthreads with a big lock to ensure that only one would run at a time. Which was kind of evil, but much more reliable. (Previously I was using my own coroutine implementation based on getcontext/setcontext.)
So, uh. I can't remember if I had a point any more; but the pain remains.
by brudgers on 1/12/16, 1:57 PM
by halayli on 1/13/16, 5:55 PM
void MyMethod(std::vector<int> my_vec) {}
std::vector<int> v{1,2,3,4};
Lthread t1{&MyMethod, v};
t1.detach()
void my_coroutine()
{
lthread_compute_begin();
ret = fibonacci(55);
lthread_compute_end();
}
by stepanhruda on 1/13/16, 5:47 PM
by geofft on 1/13/16, 4:06 PM
A co-TA and I ported the concurrency library in JOS, MIT's teaching operating system, to regular UNIX:
https://github.com/geofft/vireo
It uses the standard-ish library functions setcontext and getcontext to avoid an assembly dependency. ("POSIX.1-2008 removes the specification of getcontext(), citing portability issues, and recommending that applications be rewritten to use POSIX threads instead.")
by evmar on 1/13/16, 5:46 PM
by delinka on 1/13/16, 4:48 PM
by ghrifter on 1/13/16, 4:26 PM
Is this statement basically a do while/while(true) infinite loop?
for (;;) {
...
}
by pantalaimon on 1/13/16, 6:33 PM