From 006f9694b39aa2d500739493aca3ae9ae37f886e Mon Sep 17 00:00:00 2001 From: hidnplayr Date: Wed, 22 Jan 2014 14:08:37 +0000 Subject: [PATCH] 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 --- kernel/trunk/network/ethernet.inc | 4 ---- kernel/trunk/network/queue.inc | 33 ++++++------------------------ kernel/trunk/network/tcp_input.inc | 4 ---- 3 files changed, 6 insertions(+), 35 deletions(-) diff --git a/kernel/trunk/network/ethernet.inc b/kernel/trunk/network/ethernet.inc index e48b389eec..ca465bd001 100644 --- a/kernel/trunk/network/ethernet.inc +++ b/kernel/trunk/network/ethernet.inc @@ -86,11 +86,7 @@ ETH_input: push ebx mov esi, esp - pushf - cli add_to_queue ETH_queue, ETH_QUEUE_SIZE, sizeof.ETH_queue_entry, .fail - popf - add esp, sizeof.ETH_queue_entry xor edx, edx diff --git a/kernel/trunk/network/queue.inc b/kernel/trunk/network/queue.inc index d8b79ea544..2b9c1aabc8 100644 --- a/kernel/trunk/network/queue.inc +++ b/kernel/trunk/network/queue.inc @@ -28,7 +28,6 @@ struct queue size dd ? ; number of queued packets in this queue w_ptr dd ? ; current writing pointer in queue r_ptr dd ? ; current reading pointer - mutex MUTEX ends @@ -47,18 +46,12 @@ macro add_to_queue ptr, size, entry_size, failaddr { local .ok, .no_wrap - pusha - lea ecx, [ptr + queue.mutex] - call mutex_lock - popa + spin_lock_irqsave cmp [ptr + queue.size], size ; Check if queue isnt full jb .ok - pusha - lea ecx, [ptr + queue.mutex] - call mutex_unlock - popa + spin_unlock_irqrestore jmp failaddr .ok: @@ -76,10 +69,7 @@ local .ok, .no_wrap .no_wrap: mov [ptr + queue.w_ptr], edi - pusha - lea ecx, [ptr + queue.mutex] - call mutex_unlock - popa + spin_unlock_irqrestore } @@ -89,18 +79,12 @@ macro get_from_queue ptr, size, entry_size, failaddr { local .ok, .no_wrap - pusha - lea ecx, [ptr + queue.mutex] - call mutex_lock - popa + spin_lock_irqsave cmp [ptr + queue.size], 0 ; any packets queued? ja .ok - pusha - lea ecx, [ptr + queue.mutex] - call mutex_unlock - popa + spin_unlock_irqrestore jmp failaddr .ok: @@ -122,10 +106,7 @@ local .ok, .no_wrap pop esi - pusha - lea ecx, [ptr + queue.mutex] - call mutex_unlock - popa + spin_unlock_irqrestore } @@ -136,6 +117,4 @@ macro init_queue ptr { mov [ptr + queue.w_ptr], edi mov [ptr + queue.r_ptr], edi - lea ecx, [ptr + queue.mutex] - call mutex_init } \ No newline at end of file diff --git a/kernel/trunk/network/tcp_input.inc b/kernel/trunk/network/tcp_input.inc index 577df3f7a3..1320840b4f 100644 --- a/kernel/trunk/network/tcp_input.inc +++ b/kernel/trunk/network/tcp_input.inc @@ -43,11 +43,7 @@ TCP_input: push ebx ecx esi edi ; mind the order mov esi, esp - pushf - cli add_to_queue TCP_queue, TCP_QUEUE_SIZE, sizeof.TCP_queue_entry, .fail - popf - add esp, sizeof.TCP_queue_entry call NET_ptr_to_num4