forked from KolibriOS/kolibrios
Make network queue spinlock protected instead of mutex-protected or worse: a combination of both..
git-svn-id: svn://kolibrios.org@4510 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
8f29537721
commit
006f9694b3
@ -86,11 +86,7 @@ ETH_input:
|
|||||||
push ebx
|
push ebx
|
||||||
mov esi, esp
|
mov esi, esp
|
||||||
|
|
||||||
pushf
|
|
||||||
cli
|
|
||||||
add_to_queue ETH_queue, ETH_QUEUE_SIZE, sizeof.ETH_queue_entry, .fail
|
add_to_queue ETH_queue, ETH_QUEUE_SIZE, sizeof.ETH_queue_entry, .fail
|
||||||
popf
|
|
||||||
|
|
||||||
add esp, sizeof.ETH_queue_entry
|
add esp, sizeof.ETH_queue_entry
|
||||||
|
|
||||||
xor edx, edx
|
xor edx, edx
|
||||||
|
@ -28,7 +28,6 @@ struct queue
|
|||||||
size dd ? ; number of queued packets in this queue
|
size dd ? ; number of queued packets in this queue
|
||||||
w_ptr dd ? ; current writing pointer in queue
|
w_ptr dd ? ; current writing pointer in queue
|
||||||
r_ptr dd ? ; current reading pointer
|
r_ptr dd ? ; current reading pointer
|
||||||
mutex MUTEX
|
|
||||||
|
|
||||||
ends
|
ends
|
||||||
|
|
||||||
@ -47,18 +46,12 @@ macro add_to_queue ptr, size, entry_size, failaddr {
|
|||||||
|
|
||||||
local .ok, .no_wrap
|
local .ok, .no_wrap
|
||||||
|
|
||||||
pusha
|
spin_lock_irqsave
|
||||||
lea ecx, [ptr + queue.mutex]
|
|
||||||
call mutex_lock
|
|
||||||
popa
|
|
||||||
|
|
||||||
cmp [ptr + queue.size], size ; Check if queue isnt full
|
cmp [ptr + queue.size], size ; Check if queue isnt full
|
||||||
jb .ok
|
jb .ok
|
||||||
|
|
||||||
pusha
|
spin_unlock_irqrestore
|
||||||
lea ecx, [ptr + queue.mutex]
|
|
||||||
call mutex_unlock
|
|
||||||
popa
|
|
||||||
jmp failaddr
|
jmp failaddr
|
||||||
|
|
||||||
.ok:
|
.ok:
|
||||||
@ -76,10 +69,7 @@ local .ok, .no_wrap
|
|||||||
.no_wrap:
|
.no_wrap:
|
||||||
mov [ptr + queue.w_ptr], edi
|
mov [ptr + queue.w_ptr], edi
|
||||||
|
|
||||||
pusha
|
spin_unlock_irqrestore
|
||||||
lea ecx, [ptr + queue.mutex]
|
|
||||||
call mutex_unlock
|
|
||||||
popa
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,18 +79,12 @@ macro get_from_queue ptr, size, entry_size, failaddr {
|
|||||||
|
|
||||||
local .ok, .no_wrap
|
local .ok, .no_wrap
|
||||||
|
|
||||||
pusha
|
spin_lock_irqsave
|
||||||
lea ecx, [ptr + queue.mutex]
|
|
||||||
call mutex_lock
|
|
||||||
popa
|
|
||||||
|
|
||||||
cmp [ptr + queue.size], 0 ; any packets queued?
|
cmp [ptr + queue.size], 0 ; any packets queued?
|
||||||
ja .ok
|
ja .ok
|
||||||
|
|
||||||
pusha
|
spin_unlock_irqrestore
|
||||||
lea ecx, [ptr + queue.mutex]
|
|
||||||
call mutex_unlock
|
|
||||||
popa
|
|
||||||
jmp failaddr
|
jmp failaddr
|
||||||
|
|
||||||
.ok:
|
.ok:
|
||||||
@ -122,10 +106,7 @@ local .ok, .no_wrap
|
|||||||
|
|
||||||
pop esi
|
pop esi
|
||||||
|
|
||||||
pusha
|
spin_unlock_irqrestore
|
||||||
lea ecx, [ptr + queue.mutex]
|
|
||||||
call mutex_unlock
|
|
||||||
popa
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,6 +117,4 @@ macro init_queue ptr {
|
|||||||
mov [ptr + queue.w_ptr], edi
|
mov [ptr + queue.w_ptr], edi
|
||||||
mov [ptr + queue.r_ptr], edi
|
mov [ptr + queue.r_ptr], edi
|
||||||
|
|
||||||
lea ecx, [ptr + queue.mutex]
|
|
||||||
call mutex_init
|
|
||||||
}
|
}
|
@ -43,11 +43,7 @@ TCP_input:
|
|||||||
push ebx ecx esi edi ; mind the order
|
push ebx ecx esi edi ; mind the order
|
||||||
mov esi, esp
|
mov esi, esp
|
||||||
|
|
||||||
pushf
|
|
||||||
cli
|
|
||||||
add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail
|
add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail
|
||||||
popf
|
|
||||||
|
|
||||||
add esp, sizeof.TCP_queue_entry
|
add esp, sizeof.TCP_queue_entry
|
||||||
|
|
||||||
call NET_ptr_to_num4
|
call NET_ptr_to_num4
|
||||||
|
Loading…
Reference in New Issue
Block a user