Mostly an experiment to explore scratches VM and its threading model. The example shows two threads control the active costume over a mutex. Note each thread is run concurrently, not in parallel. thread functions: thread : create (ID) = create a new thread of id (ID) thread : start (ID) = launches id (use after calling create) thread : remove (ID) = stops id thread : yield = forces a yield mutex functions: mutex : create = sets up a mutex, use first mutex : acquire blocking (LOCKid) = spins if cant mutex : try acquire (LOCKid) = returns success mutex : free (LOCKid) = release lock "completion count" show the round robin task list has been completed and is restarted
From what i've learned: * VM steps through threads in a round-robin fashion * blocks like WAIT trigger a schedule-and-yield * end of loops also yield * warp functions locks the thread until you use something that yields, i.e. any loop or wait block I can't figure out how to make a locking wait, and a pure lock (with loops) without it forcing a yield. If anyone knows comment below. My goal was to implement a watchdog with "completion count" to check if any thread has locked up, but since there is no direct control of yielding, I'm not sure if thats possible.