Page 1 of 1
How to create a multicore OS ?
Posted: Sun May 28, 2017 2:21 am
by Coconut9
I mean who a can enable all the cores and force them to execute instructions ?
Re: How to create a multicore OS ?
Posted: Sun May 28, 2017 4:10 am
by sortie
Re: How to create a multicore OS ?
Posted: Sun May 28, 2017 4:29 am
by iansjack
Don't force your cores to execute instructions. Ask them nicely; it's only polite.
Re: How to create a multicore OS ?
Posted: Tue Jun 27, 2017 4:30 pm
by xmm15
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.
Re: How to create a multicore OS ?
Posted: Wed Jun 28, 2017 12:45 am
by iansjack
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.