diff --git a/kernel/trunk/core/irq.inc b/kernel/trunk/core/irq.inc index 241314465b..d281dc7e8b 100644 --- a/kernel/trunk/core/irq.inc +++ b/kernel/trunk/core/irq.inc @@ -9,27 +9,6 @@ IRQ_RESERVED equ 16 IRQ_POOL_SIZE equ 48 - -macro __list_add new, prev, next -{ - mov [next+LHEAD.prev], new - mov [new+LHEAD.next], next - mov [new+LHEAD.prev], prev - mov [prev+LHEAD.next], new -} - -macro list_add new, head -{ - mov eax, [head+LHEAD.next] - __list_add new, head, eax -} - -macro list_add_tail new, head -{ - mov eax, [head+LHEAD.prev] - __list_add new, eax, head -} - uglobal align 16 diff --git a/kernel/trunk/core/sched.inc b/kernel/trunk/core/sched.inc index 4548029a4f..f2fa695ea3 100644 --- a/kernel/trunk/core/sched.inc +++ b/kernel/trunk/core/sched.inc @@ -221,8 +221,7 @@ do_change_task: struc MUTEX_WAITER { - .next rd 1 - .prev rd 1 + .list LHEAD .task rd 1 .sizeof: }; @@ -235,10 +234,9 @@ end virtual align 4 mutex_init: - lea eax, [ecx+MUTEX.next] + mov [ecx+MUTEX.wait.next], ecx + mov [ecx+MUTEX.wait.prev], ecx mov [ecx+MUTEX.count],1 - mov [ecx+MUTEX.next], eax - mov [ecx+MUTEX.prev], eax ret @@ -253,16 +251,9 @@ mutex_lock: pushfd cli - push esi sub esp, MUTEX_WAITER.sizeof - mov eax, [ecx+MUTEX.prev] - lea esi, [ecx+MUTEX.next] - - mov [ecx+MUTEX.prev], esp - mov [esp+MUTEX_WAITER.next], esi - mov [esp+MUTEX_WAITER.prev], eax - mov [eax], esp + list_add_tail esp, ecx ;esp= new waiter, ecx= list head mov edx, [TASK_BASE] mov [esp+MUTEX_WAITER.task], edx @@ -278,19 +269,18 @@ mutex_lock: call change_task jmp .forever @@: - mov edx, [esp+MUTEX_WAITER.next] - mov eax, [esp+MUTEX_WAITER.prev] + mov edx, [esp+MUTEX_WAITER.list.next] + mov eax, [esp+MUTEX_WAITER.list.prev] - mov [eax+MUTEX_WAITER.next], edx - cmp [ecx+MUTEX.next], esi - mov [edx+MUTEX_WAITER.prev], eax + mov [eax+MUTEX_WAITER.list.next], edx + mov [edx+MUTEX_WAITER.list.prev], eax + cmp [ecx+MUTEX.wait.next], ecx jne @F mov [ecx+MUTEX.count], 0 @@: add esp, MUTEX_WAITER.sizeof - pop esi popfd .done: ret @@ -303,9 +293,8 @@ mutex_unlock: pushfd cli - lea edx, [ecx+MUTEX.next] - mov eax, [edx] - cmp eax, edx + mov eax, [ecx+MUTEX.wait.next] + cmp eax, ecx mov [ecx+MUTEX.count], 1 je @F diff --git a/kernel/trunk/kernel32.inc b/kernel/trunk/kernel32.inc index 56930f556e..c6cc0b5d89 100644 --- a/kernel/trunk/kernel32.inc +++ b/kernel/trunk/kernel32.inc @@ -196,9 +196,8 @@ end virtual struc MUTEX { + .wait LHEAD .count rd 1 - .next rd 1 - .prev rd 1 } virtual at 0 diff --git a/kernel/trunk/macros.inc b/kernel/trunk/macros.inc index 1a90f44f6c..45e677c486 100644 --- a/kernel/trunk/macros.inc +++ b/kernel/trunk/macros.inc @@ -107,3 +107,24 @@ macro Mov op1,op2,op3 ; op1 = op2 = op3 mov op2,op3 mov op1,op2 } + +macro __list_add new, prev, next +{ + mov [next+LHEAD.prev], new + mov [new+LHEAD.next], next + mov [new+LHEAD.prev], prev + mov [prev+LHEAD.next], new +} + +macro list_add new, head +{ + mov eax, [head+LHEAD.next] + __list_add new, head, eax +} + +macro list_add_tail new, head +{ + mov eax, [head+LHEAD.prev] + __list_add new, eax, head +} +