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
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

View File

@ -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

View File

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

View File

@ -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
}