Page 1 of 1
Threading differences?
Posted: Mon Mar 27, 2006 1:41 pm
by xsdev
I was wondering if anyone could point me at any documentation that compares and contrasts the differences between processes and thread implementations on Windows versus Linux. In the meantime I'll be googling to see what I can come up with on my own. This is not a school project or anything like that. I'm just curious.
Thanks,
Steven
Re:Threading differences?
Posted: Mon Mar 27, 2006 2:27 pm
by proxy
well windows uses a more academic definition of threads/processes (which i happen to like better)
here's how it works on windows:
a process is an address space and any associate data associated with the program occupying it. This includes what regions are where and what access they have. They have also included much data for security purposes. A process may own one or more threads.
a thread is a stream of execution and has associated with it a stack. It litterally boils down to a context (register state and such) and some minor bookeeping information. A thread is what the scheduler deals with, and has a few possible states including (but not limitied to) "running", "ready to run" and "blocked".
Linux kind of melded the two concepts together.
Basically in linux, a process as well as the usual process stuff, has a context like a thread. When you want to spawn a new thread, it really creates a new process and shares the code/data/bss/heap pages between them creating the functional equivalent of threads.
In Linux processes are scheduled since it is the only unit of execution.
In my OS, I am much closer to the Windows model, however I have made a few changes. One nice side effect of the Linux model is that each thread gets a stack in the same location and one stack can't "run into" another by growing too much. This is because each "thread" in linux has it's own page dir and does not share stack related pages. On windows all the thread stacks exist in the same address space.
My implementation is to manually swap the page table entries associated with stacks on task switch instead of reloading the whole page directory. This will make my model very much like windows, but my stacks will not coexist with each other in the address space.
proxy
Re:Threading differences?
Posted: Tue Mar 28, 2006 1:54 pm
by xsdev
Thanks for the reply. That makes more sense now.