Page 2 of 2

Re: SMP Parallel problem

Posted: Wed Oct 19, 2011 8:41 pm
by gerryg400
...and i have 8 cores emulated
Oh. I thought you were running on bare metal ! Which emulator are you using ?

If I were trying to debug this problem I would disassemble the executable and examine it. Can you post the disassembled executable ?

Re: SMP Parallel problem

Posted: Wed Oct 19, 2011 9:29 pm
by lemonyii
congratulations gerryg400! YOU hit the boom!
the solution is so simple:

Code: Select all

....
		kbd_init();
		wait = false;
	} else {
		vga_prt( "A" );
		//cpu_init();
		while( wait );
	}
	vga_prt( "B" );
	//sched();
	while(1);	
}
Nothing different right? And i even turned on -O2!
the key problem is, vga_prt is with no lock! the reason is, when the wait is set false by bsp, all aps go to print at a same time to print "B", (but "A" is printed seperately, because bsp release them seperately, with an allocation between them. ), so we can see only one 'B'.
how i found it is just because i redefined page table in bootloader to map a larger space for kernel at the beginning, and i suddenly see 7 As and 3 Bs... so, you know...
gerryg400 wrote:Oh. I thought you were running on bare metal ! Which emulator are you using ?
i don't have a bare metal, u will know that if u are in china. chinese students even professors have little device for their research, not like u. china is not poor now, but its people is even poorer than before. i love my country more than u can feel, but i hate its political environment. u think China is People's Republic? i will tell u NO!
but i use bochs for multi-core, sometimes virtualbox, qemu just for single core because it's really slow for SMP.
If I were trying to debug this problem I would disassemble the executable and examine it. Can you post the disassembled executable ?
i disasm sometimes but not often, since i would combine printing things and bochsdbg. disasm is not a good way as your kernel grows. but combine symbol table and bochsdbg (breakpoint, disassemble little piece of code) would be better. i don't have better way.
keeping the whole kernel arch and its logic in your brain clearly, will help a lot i think.

thx

Re: SMP Parallel problem

Posted: Fri Oct 21, 2011 9:37 am
by Brendan
Hi,
lemonyii wrote:congratulations gerryg400! YOU hit the boom!
the solution is so simple:
Cool :)


Gerry400 already got one of my "at least 2 problems" (and found more that I didn't even notice!). The other one hasn't been mentioned yet (a race condition): The AP CPUs could call "vga_prt()" before the BSP has called "vga_init();". To fix that the AP CPUs should do the "wait(wait);" before they do "vga_prt( "C" );".


Cheers,

Brendan