I have got multi-tasking up and running (with processes), and I was wondering how to implement threads.
If I understand the wiki (Process and Threads) correctly, implementing thread support should be very simple - adding a thread could simply add a 'process' which uses the same address space as the parent process but has a separate stack.
This left me wondering, what's the catch?
Multi-tasking - Processes and Threads
Multi-tasking - Processes and Threads
Currently developing Lithium OS (LiOS).
Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
Re: Multi-tasking - Processes and Threads
Hi,
Basically; a process has a virtual address space and a few other things that the scheduler doesn't care about, and contains one or more threads that the scheduler does care about. When a process is created, its initial thread is also created (and it's this initial thread that begins executing at the process' entry point). If a process has no threads (e.g. its last remaining thread has terminated) then the "thread container" is destroyed.
Cheers,
Brendan
I find it much easier to think of a process as a container that contains one or more threads.BMW wrote:I have got multi-tasking up and running (with processes), and I was wondering how to implement threads.
If I understand the wiki (Process and Threads) correctly, implementing thread support should be very simple - adding a thread could simply add a 'process' which uses the same address space as the parent process but has a separate stack.
This left me wondering, what's the catch?
Basically; a process has a virtual address space and a few other things that the scheduler doesn't care about, and contains one or more threads that the scheduler does care about. When a process is created, its initial thread is also created (and it's this initial thread that begins executing at the process' entry point). If a process has no threads (e.g. its last remaining thread has terminated) then the "thread container" is destroyed.
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
Re: Multi-tasking - Processes and Threads
That makes much more sense. Thanks.Brendan wrote: I find it much easier to think of a process as a container that contains one or more threads.
Basically; a process has a virtual address space and a few other things that the scheduler doesn't care about, and contains one or more threads that the scheduler does care about. When a process is created, its initial thread is also created (and it's this initial thread that begins executing at the process' entry point). If a process has no threads (e.g. its last remaining thread has terminated) then the "thread container" is destroyed.
Cheers,
Brendan
Currently developing Lithium OS (LiOS).
Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."
Recursive paging saves lives.
"I want to change the world, but they won't give me the source code."