How to create a multicore OS ?
- Coconut9
- Member
- Posts: 51
- Joined: Sat May 20, 2017 1:25 am
- Location: PCI bus: 3, slot: 9, function: 5
How to create a multicore OS ?
I mean who a can enable all the cores and force them to execute instructions ?
How people react when a new update of your OS is coming:
Linux user: Cool, more free stuff!
Mac user: Ooh I have to pay!
Windows user: Ah not again!
Linux user: Cool, more free stuff!
Mac user: Ooh I have to pay!
Windows user: Ah not again!
Re: How to create a multicore OS ?
Don't force your cores to execute instructions. Ask them nicely; it's only polite.
Re: How to create a multicore OS ?
Basically:
Computer starts with 1 logical processor, others are halted.
Find the number of cpus by scanning memory for mp structures
Use apic to send SIPI, an interrupt that will wake up the other cpus. When sending sipi, you provide an address that you want your cpus to start executing from.
Once they start executing, setup long mode, setup a timer uaing their local apic and make that timer execute the scheduling function. Now you have tasks running on each cpus note that you task list will be global and all cpus will compete to run a task. A task should not run on 2 cpu at the same time.
The wiki page referenced above is a good start. Intel manuals are your best friend.
Computer starts with 1 logical processor, others are halted.
Find the number of cpus by scanning memory for mp structures
Use apic to send SIPI, an interrupt that will wake up the other cpus. When sending sipi, you provide an address that you want your cpus to start executing from.
Once they start executing, setup long mode, setup a timer uaing their local apic and make that timer execute the scheduling function. Now you have tasks running on each cpus note that you task list will be global and all cpus will compete to run a task. A task should not run on 2 cpu at the same time.
The wiki page referenced above is a good start. Intel manuals are your best friend.
Re: How to create a multicore OS ?
The task list doesn't have to be global. You can always set up per-cpu task lists and determine which CPU to run a process on, rather than letting it happen randomly. This can simplify scheduling but it is then up to you to ensure that processes are spread evenly amongst CPUs.
Also, you don't need to use individual timers for each CPU. It's possible to have just one timer running, which then notifies the other CPUs.
Also, you don't need to use individual timers for each CPU. It's possible to have just one timer running, which then notifies the other CPUs.