Repos / kernel.git / commitdiff
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: dff2cdf)
raw | patch | inline | side by side (parent: dff2cdf)
| author | zhaoyanbai <zhaoyanbai@126.com> | |
| Tue, 6 Jun 2023 01:27:23 +0000 (09:27 +0800) | ||
| committer | zhaoyanbai <zhaoyanbai@126.com> | |
| Tue, 6 Jun 2023 01:27:23 +0000 (09:27 +0800) |
| drivers/ide.h | patch | blob | history | |
| include/semaphore.h | patch | blob | history | |
| kernel/task_user.c | patch | blob | history |
diff --git a/drivers/ide.h b/drivers/ide.h
--- a/drivers/ide.h
+++ b/drivers/ide.h
// 提出请求的任务用这个字段互斥地添加请求到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
--- a/include/semaphore.h
+++ b/include/semaphore.h
// 只会唤醒进程,但不会立即重新调度进程
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) \
(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
--- a/kernel/task_user.c
+++ b/kernel/task_user.c
"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;");
+ }
+ }
}
}