sync with r2143 except for a typo

git-svn-id: svn://kolibrios.org@2146 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
CleverMouse 2011-09-02 19:32:21 +00:00
parent a632fb94b0
commit a3388c45de
4 changed files with 33 additions and 45 deletions

View File

@ -9,27 +9,6 @@ IRQ_RESERVED equ 16
IRQ_POOL_SIZE equ 48 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 uglobal
align 16 align 16

View File

@ -221,8 +221,7 @@ do_change_task:
struc MUTEX_WAITER struc MUTEX_WAITER
{ {
.next rd 1 .list LHEAD
.prev rd 1
.task rd 1 .task rd 1
.sizeof: .sizeof:
}; };
@ -235,10 +234,9 @@ end virtual
align 4 align 4
mutex_init: 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.count],1
mov [ecx+MUTEX.next], eax
mov [ecx+MUTEX.prev], eax
ret ret
@ -253,16 +251,9 @@ mutex_lock:
pushfd pushfd
cli cli
push esi
sub esp, MUTEX_WAITER.sizeof sub esp, MUTEX_WAITER.sizeof
mov eax, [ecx+MUTEX.prev] list_add_tail esp, ecx ;esp= new waiter, ecx= list head
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
mov edx, [TASK_BASE] mov edx, [TASK_BASE]
mov [esp+MUTEX_WAITER.task], edx mov [esp+MUTEX_WAITER.task], edx
@ -278,19 +269,18 @@ mutex_lock:
call change_task call change_task
jmp .forever jmp .forever
@@: @@:
mov edx, [esp+MUTEX_WAITER.next] mov edx, [esp+MUTEX_WAITER.list.next]
mov eax, [esp+MUTEX_WAITER.prev] mov eax, [esp+MUTEX_WAITER.list.prev]
mov [eax+MUTEX_WAITER.next], edx mov [eax+MUTEX_WAITER.list.next], edx
cmp [ecx+MUTEX.next], esi mov [edx+MUTEX_WAITER.list.prev], eax
mov [edx+MUTEX_WAITER.prev], eax cmp [ecx+MUTEX.wait.next], ecx
jne @F jne @F
mov [ecx+MUTEX.count], 0 mov [ecx+MUTEX.count], 0
@@: @@:
add esp, MUTEX_WAITER.sizeof add esp, MUTEX_WAITER.sizeof
pop esi
popfd popfd
.done: .done:
ret ret
@ -303,9 +293,8 @@ mutex_unlock:
pushfd pushfd
cli cli
lea edx, [ecx+MUTEX.next] mov eax, [ecx+MUTEX.wait.next]
mov eax, [edx] cmp eax, ecx
cmp eax, edx
mov [ecx+MUTEX.count], 1 mov [ecx+MUTEX.count], 1
je @F je @F

View File

@ -196,9 +196,8 @@ end virtual
struc MUTEX struc MUTEX
{ {
.wait LHEAD
.count rd 1 .count rd 1
.next rd 1
.prev rd 1
} }
virtual at 0 virtual at 0

View File

@ -107,3 +107,24 @@ macro Mov op1,op2,op3 ; op1 = op2 = op3
mov op2,op3 mov op2,op3
mov op1,op2 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
}