[OSy] Problem se statickou strukturou
Martin Cetkovský
martin at alikuvkoutek.cz
Wed Dec 5 23:15:15 CET 2007
Ahoj,
tak jsme jeste trochu badali a deje se nasledujici. Pri zavolani metody init_memory se adresa sledovane staticke promenne zmeni z 0x80020BB8 (pred vypisem Memory) na 0x8001FED8 (po kontrole v init_memory). Vzhledem k tomu, ze mapovanou pamet mame 127 kB (do 0x1FBFF), pak az od 0x20000. Pro jistotu opakuji, ze jeste nedoslo k inicializaci pameti ani scheduleru a nebyl volan zadny malloc ani alokovan ramec (to vim s jistotou), takze IMHO nemelo sanci dojit k preplanovani ani pokropeni pameti vlastnimi silami. Opravdu mne uz nenapada, co s tim. Ma nekdo nejaky tip? Poustime to v labu.
Mame nasledujici kod:
...
puts("\n\tMemory ");
___stop();
if (someglobals.firstlock.value == 0xFFFFFFFF)
panic("c");
init_memory();
....
void init_memory(void)
{
unsigned int start;
unsigned int end;
unsigned int size;
unsigned int * p;
if (someglobals.firstlock.value == 0xFFFFFFFF)
___stop();
...
}
Zde je vypis v assembleru.
Memory [msim] set trace on
[msim] g
8000FEF8 lui v0, 0x8002 # 0x8002=32770, v0: 0x0->0x80020000, v1: 0x0->0x400004, a0: 0x0->0x80021450, sp: 0x0->0x8000b9b8, fp: 0x0->0x8000b9b8, ra: 0x0->0x8000fef4, cp0_index: 0x00000000->0x0000002f, cp0_entryhi: 0x00000000->0x000bc000
8000FEFC addiu v0, v0, 0x2f0 # 0x2f0=752, v0: 0x80020000->0x800202f0
8000FF00 lw v1, 0x8a8(v0) # 0x8a8=2216, v1: 0x400004->0x0
8000FF04 addiu v0, 0, 0xffff # 0xffffffff=65535, v0: 0x800202f0->0xffffffff
8000FF08 bne v1, v0, 0x4 # 0x4=4
8000FF0C nop
8000FF1C jal +0xf544 # 0xf544=62788, ra: 0x8000fef4->0x8000ff24
8000FF20 nop
8000F544 addiu sp, sp, 0xffd8 # 0xffffffd8=65496, sp: 0x8000b9b8->0x8000b990
8000F548 sw ra, 0x24(sp) # 0x24=36
8000F54C sw fp, 0x20(sp) # 0x20=32
8000F550 addu fp, sp, 0 # fp: 0x8000b9b8->0x8000b990
8000F554 lui v0, 0x8002 # 0x8002=32770, v0: 0xffffffff->0x80020000
8000F558 addiu v0, v0, 0xf610 # 0xfffff610=62992, v0: 0x80020000->0x8001f610
8000F55C lw v1, 0x8a8(v0) # 0x8a8=2216, v1: 0x0->0xffffffff
8000F560 addiu v0, 0, 0xffff # 0xffffffff=65535, v0: 0x8001f610->0xffffffff
8000F564 bne v1, v0, 0x1a # 0x1a=26
8000F568 nop
8000F56C ---
[msim]
> -----Original Message-----
> From: osy-bounces at dsrg.mff.cuni.cz [mailto:osy-
> bounces at dsrg.mff.cuni.cz] On Behalf Of Martin Cetkovský
> Sent: Wednesday, December 05, 2007 2:11 PM
> To: 'Operating Systems Course'
> Subject: [OSy] Problem se statickou strukturou
>
> Ahoj,
>
> mame problemy se statickou strukturou, konkretne pri inicializaci
> spinlocku. Prikladam relevantni informace.
>
> static struct{
> ...
> struct spinlock firstlock;
> struct spinlock secondlock;
> } someglobals;
>
> struct spinlock{
> volatile int value;
> };
>
> void spinlock_init(struct spinlock * lock)
> {
> printk_locked("%x, %x\n", lock->value, SPINLOCK_UNLOCKED);
> lock->value = SPINLOCK_UNLOCKED;
> printk_locked("%x\n", lock->value);
> }
>
> Inicializaci spinlocku volame nasledovne.
> spinlock_init(&someglobals.firstlock);
> spinlock_init(&someglobals.secondlock);
> printk_locked("after %x, value %x", &someglobals.secondlock,
> someglobals.secondlock.value);
>
> Vypsane hodnoty jsou nasledujici (pricemz u nekolika predchozich
> jsou hodnoty spravne - 0x0 misto 0xFF*):
> 0xFFFFFFFF, 0x0
> 0xFFFFFFFF
> 0xFFFFFFFF, 0x0
> 0xFFFFFFFF
> after 0x8001FFD8, value 0xFFFFFFFFA
>
> Bezime na single-CPU a nastava jiz pri inicializaci pameti, cili
> scheduler ani malloc se dosud nemaji sanci projevit.
>
> Mate nekdo tip, co s tim je? Nejak to nemuzeme najit.
>
> Diky,
>
> Martin Cetkovský
>
>
>
> _______________________________________________
> OSy mailing list
> OSy at dsrg.mff.cuni.cz
> https://dsrg.mff.cuni.cz/mailman/listinfo/osy
More information about the NSWI004
mailing list