From: acevest Date: Tue, 6 Jun 2023 01:27:23 +0000 (+0800) Subject: 用semaphore_t定义mutex_t X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zpipe.c?a=commitdiff_plain;h=c189f12de5b8358d572834c2ff0e8730c1bcb0ff;p=kernel.git 用semaphore_t定义mutex_t --- diff --git a/drivers/ide.h b/drivers/ide.h index 148d63e..4043c31 100644 --- a/drivers/ide.h +++ b/drivers/ide.h @@ -180,7 +180,7 @@ typedef struct _ide_pci_controller { // 提出请求的任务用这个字段互斥地添加请求到request_queue // 同时也和disk任务互斥 - semaphore_t request_mutex; + mutex_t request_mutex; // 请求队列 disk_request_queue_t request_queue; diff --git a/include/semaphore.h b/include/semaphore.h index 70d86ec..f76b5d5 100644 --- a/include/semaphore.h +++ b/include/semaphore.h @@ -32,6 +32,8 @@ void down(semaphore_t *s); // 只会唤醒进程,但不会立即重新调度进程 void up(semaphore_t *s); +typedef semaphore_t mutex_t; + #define DECLARE_MUTEX(name) semaphore_t name = SEMAPHORE_INITIALIZER(name, 1) #define INIT_MUTEX(ptr) \ @@ -39,5 +41,5 @@ void up(semaphore_t *s); (ptr)->cnt = 1; \ INIT_LIST_HEAD(&((ptr)->wait_list)); \ } while (0) -void mutex_lock(semaphore_t *); -void mutex_unlock(semaphore_t *); +void mutex_lock(mutex_t *); +void mutex_unlock(mutex_t *); diff --git a/kernel/task_user.c b/kernel/task_user.c index d5ec98e..75977aa 100644 --- a/kernel/task_user.c +++ b/kernel/task_user.c @@ -50,6 +50,12 @@ void __ring3text__ __attribute__((__aligned__(PAGE_SIZE))) ring3_entry() { "sysexit_return_address:" : "=a"(__sysc_ret__) : "a"(SYSC_WAIT), "c"(ring3_entry)); + + for (int i = 100000000; i > 0; i--) { + for (int j = 1; j > 0; j--) { + asm("nop;nop;nop;"); + } + } } }