Finished implementing threading in user space for my kernel (well, not the thread scheduling which is still done in hardware, but the creation of a thread from the user space).

This is how this looks like:


And here is the code responsible for this:
Code:
void thread()
{
	sys_printColor("Secondary thread!\n", vd_color_red); // Simply tell everyone that we are here
}

void test()
{
	sys_print("Hello World\n");

	uint32_t id = sys_threadAttach(thread, 4); // Attach a new thread to the process with thread() as function
	sys_threadJoin(id); // Wait for the newly created thread to exit

	sys_print("Thread exited\n");
}



The "Joining thread 1" message is printed by the kernel for debugging purposes. I'm quite happy with the result since I stopped working on it because of a bug that gave me great headache a few weeks ago and today I decided to try it again and got it working in ~20 minutes laugh
The really nice thing is that I can now block threads based on predicates and unblock them when these predicates turn out to be true, in the thread joining case that means that the predicate is that the other thread exits.

If someone wants to read more about this small project, here is a blogpost where I go into some details and also posted a link to the source code repo: http://widerwille.com/blog/?article=articles:article4


Shitlord by trade and passion. Graphics programmer at Laminar Research.
I write blog posts at feresignum.com