flat assembler
Message board for the users of flat assembler.

Index > OS Construction > SMP tutorial or help

Author
Thread Post new topic Reply to topic
fonolite



Joined: 14 Dec 2005
Posts: 32
fonolite 26 Apr 2006, 06:51
Hi, I'm adding SMP code in my basic kernel.
I'm a newbie for SMP. Smile

Searching from [0xE0000], I found MP configuration table in MS-DOS.

Following MP configuration table, I can find only 1 processor entry.
(Entry Type Code = 0)

But my cpu is dual core.(Intel smithfield)

How can I find Application Processor entry?



ps) Any sample codes for SMP newbie? Smile
Post 26 Apr 2006, 06:51
View user's profile Send private message Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 28 Apr 2006, 11:10
If you have some time and a cdrw, you could burn the attached iso image and boot it. If there stands something like "2 CPUs and 1 IO-APICs found" then I can help you. Otherwise I have to look how to init and find multi core cpus! I think there was something with cpuid. There you have to look for the number of cores and logical cpus.


Description:
Download
Filename: os-test.zip
Filesize: 13.86 KB
Downloaded: 253 Time(s)

Post 28 Apr 2006, 11:10
View user's profile Send private message Reply with quote
fonolite



Joined: 14 Dec 2005
Posts: 32
fonolite 01 May 2006, 01:23
Thanks!
I'll try it and report soon.
Post 01 May 2006, 01:23
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 01 May 2006, 14:53
Should it work under emulator too? I've made some _MP_ detection myself and it works under QEMU. Too bad I don't have any experience with interrupts to send an IPI to another CPU. Only one of them is working and the other remains halted - according to Intel it is waiting initiative from the bootstrap, but :S how!?

Ok, here's what I've got:
Code:
OS-Loader...
drive: 0xE0 ,fs: ISO9660
kernel: SYSTEM/KERNEL, size: 00005558, loaded at 00100000
    

sometimes it even halts at the 3rd line on "ke" (the first two letters)
Post 01 May 2006, 14:53
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 01 May 2006, 15:45
Yes it should work under an emulator, too. I have tested it under Qemu and Bochs and it does work. I think you tested it with >14 CPUs. I don´t know why but it wont work with >14 CPUs (the detection) and the os doesn´t work with >10 CPUs. So please test it with max 8 CPUs I know that it works there, because I can test it in Bochs with that and until there is >8 CPU support in Bochs I have to wait to find the problem.

You said that it sometimes even doesn´t get till after the kernel is loaded?! This is strange. I haven´t seen this in any emu and on any pc. Have you only tested it in qemu or also on a real pc? Also which version of qemu does you use?

Edit::

It is also possible that you´ve tested it under the x86-64 qemu, because I also tested it there now and it seems that qemu crashed. But this has to be a failure of qemu, because under bochs it does work also under a 64bit cpu.
Post 01 May 2006, 15:45
View user's profile Send private message Reply with quote
fonolite



Joined: 14 Dec 2005
Posts: 32
fonolite 02 May 2006, 00:41
Hi, this is only what I've got

Code:
OS-Loader...
drive: 0xEF ,fs: ISO9660
kernel: SYSTEM/KERNEL, size: 00005558, loaded at 00100000    


What does "drive" mean?



ps) Anyway, CPUID with eax=1, the number of logical core is 2.
Post 02 May 2006, 00:41
View user's profile Send private message Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 02 May 2006, 04:50
Drive is the bios number for your cd-drive. When you also doesn´t get to the cpu detection routine then I think I have to do some more work on it. The only think that is missing are some delays, but on the pcs I have tested the code it worked.

Anyway, I´ve read the documentation and it says that also on a dual core pc you have to have 2 cpu entries in the mp configuration table! So you have to go trough it.

I will post some more details on how to start the aps when I´m back home!
Post 02 May 2006, 04:50
View user's profile Send private message Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 25 Jul 2006, 16:00
It has been a while till I looked at my smp init code and I modified it to also use same delay for the other cpus to get up!

This is a debug build and it would be nice if some could run it on a real pc. It is equal if it is an uni cpu system or a smp system, but a smp system would be better! When you´ve tested it, you should say what it printed on your screen!


Description:
Download
Filename: os-test.zip
Filesize: 14.58 KB
Downloaded: 233 Time(s)

Post 25 Jul 2006, 16:00
View user's profile Send private message Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 29 Jul 2006, 16:32
Is there no one who tested?

Now I have a new version. This one uses ACPI (if it is available) for detecting cpus and io-apics. It would be nice if you could test it!


Description:
Download
Filename: os-test-29.07.2006.zip
Filesize: 14.9 KB
Downloaded: 231 Time(s)

Post 29 Jul 2006, 16:32
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 31 Jul 2006, 10:07
In QEMU upto 13 CPUs can be started (wierd number) and until then it works okay, but when there are 255 CPUs, it just starts 13 of them and gives an error...
Haven't tried on a real PC yet.

It prints almost the same stuff as before:
Code:
OS-Loader...
drive E0, ISO9660
kernel size 5899 @ 100000

;These next lines are interesting:
ABFound 13 CPUs and 1 IO-APICs
_
    

The line before the last printed line has A, B and F and the A is printed
before the BFound.... text appears

P.S. I'm very interested in the SMP topic, but I was on a vacation and touring Europe for the past 10 days Razz Now I'm getting back on track...
Post 31 Jul 2006, 10:07
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 31 Jul 2006, 10:20
On my qemu (newest version) it can start up to 14 cpus. But I will try to check out what the problem is. The problem is that it is not that easy with qemu and bochs doesn´t support >8 cpus at the moment Sad

Edit::

I found the function which makes the problems, my slab allocator. But I haven´t found the reason or the right code which fails Sad
Post 31 Jul 2006, 10:20
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 01 Aug 2006, 10:29
Maybe its me but my tries on QEMU have always failed. I could start at most 2 CPUs (1 BSP+1 AP) :S and they keep halting. Maybe its that I don't give them any pause (delay).

I think I'm still too n00b in interrupts and mapped memory Razz - is your code in C? I made it in ASM and because everything else is C, I can't be sure of my translation and understanding of it (the code).
Post 01 Aug 2006, 10:29
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 01 Aug 2006, 20:25
My whole OS is in asm, because I don´t realy like C for that. I´m using cpu opcodes for which you need to write a loop in C and this is not so effective!

Tomorrow I needn´t to work, so maybe I could write a simple algorithm to start up other cpus!

For debugging bochs is better than qemu! So give it a try.
Post 01 Aug 2006, 20:25
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 02 Aug 2006, 08:04
Sorry, I can't remember all the OSs out there :S give me a hint on what you are doing - is there a link or something? There is no WWW in your profile Sad

I'm glad to hear its in asm - I don't know why I suggested C Razz

I will try Bochs someday, but I've already accustomed to QEMUs keyboard shortcuts and its console commands Smile
Post 02 Aug 2006, 08:04
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 02 Aug 2006, 08:50
Yeah, I have no page for my os Sad I wanted to make one, but I haven´t found the time for that and os programming is much more interesting!

You may have a look over here: http://www.osdever.net/tutorials/pdf/mp.pdf

There you can get how to detect the number of cpus in a system. If you want I can give you my smp init function.
Post 02 Aug 2006, 08:50
View user's profile Send private message Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 02 Aug 2006, 15:23
I finally found the failures (yes, I found more than I needed Wink ) in my slab allocator and then I also found a failure in my gdt code and now I can run on PCs with 255 cpus (only tested with qemu) Twisted Evil

@Madis731

Maybe you could show me your code and I can help you with the start-up code for the cpus!?

Edit::

I just read a old post of you and how do you know the number of the cpus which have been started up in qemu?

Edit::

Even newer code, now it should also run on pcs where the apic is deactivated, but I can´t test it, because I have no such pc available. So please test it and say if it works for you.


Description:
Download
Filename: os-test-02.08.2006.zip
Filesize: 15.04 KB
Downloaded: 229 Time(s)

Post 02 Aug 2006, 15:23
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 03 Aug 2006, 08:08
@Flashburn: In QEMU you can press Ctrl+Alt+2 and type 'info cpus'. I'm still waiting because it takes a lot of time to start up all those 255 CPUs Razz
Half of them already in ~30 seconds...

But it seems to be working Wink

You gave me that link and I saw some new info that I didn't know before. I think I'm going to start over and search for something I missed before. Maybe I have just been too lazy and I didn't care to look carefully in the _MP_s, but I'll post if anything comes up (success & failures...).

EDIT: I guess it would be much faster with REAL 255 CPUs because they all start at once, but there should be a progressbar in QEMU Razz - 220 CPUs (AP) and counting. Already over 5 minutes. I think that every started AP will increase load on emulation :S

EDIT2: and finally after 6 or 7 minutes (didn't know that I have to time it Smile ) it finished with a message that "Found 255 CPUs and 0 IO-APICs"
Post 03 Aug 2006, 08:08
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 03 Aug 2006, 08:21
On my pc it takes not so long (amd xp 1900+) and it has to find a io-apic, because there is no smp system without io-apic. Which qemu version do you use?
Post 03 Aug 2006, 08:21
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 03 Aug 2006, 09:04
Still 8, I'm planning on using 8.2 and I wonder why it tells my 1 CPU (in the init), I have Dual-core I know: T2500@2GHz
and with many CPUs it screams out "Could not open '\\.\kqemu' - QEMU acceleration layer not activated" about number of CPU times Very Happy

With 25CPU I tested - it found one APIC and that is fine - it also took only 6 seconds. Maybe I need to download the accelerator I read somewhere...

EDIT: And when I thought that I should use the 64-bit variant, now it doesn't
work at all - just hangs. I wonder why it does that because it should be
backward compatible and well...I don't know.
Post 03 Aug 2006, 09:04
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
FlashBurn



Joined: 06 Jan 2005
Posts: 87
FlashBurn 03 Aug 2006, 09:19
I have the same problem with the 64bit version of qemu, but with the 64bit version of bochs it does work Question I´m using qemu 0.8.2 w/o kqemu and it takes only 3-4 seconds for me.

I will test if I can find teh reason why it doesn´t work with the 64bit qemu!
Post 03 Aug 2006, 09:19
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.