// 因为可能有的进程调用了write、read后再直接调用brelse
// 虽然此时ref_count为0,但io操作标记的b->locked并未结束
// 所以需要在此等待其结束
- while (b->locked == 1) {
- // 此时是不用担心wake_up在这个sleep_on之前调用
- }
+ wait_event(&b->waitq_lock, b->locked == 0);
// 找到了
b->block = block;
b->page = page;
b->uptodate = 0;
b->locked = 0;
+ init_wait_queue_head(&b->waitq_lock);
list_init(&b->node);
assert(NULL != b->data);
#include <mm.h>
#include <page.h>
#include <system.h>
+#include <wait.h>
typedef struct bbuffer {
uint32_t block; // block number
dev_t dev;
page_t *page;
list_head_t node;
+ wait_queue_head_t waitq_lock;
uint16_t block_size; // block size
uint16_t uptodate : 1;
uint16_t locked : 1;
void schedule();
-void wake_up(wait_queue_head_t *wqh);
-
extern task_union root_task;
extern void load_cr3(task_union *tsk);
// 如果s->cnt == 0 会重新调度进程
volatile void down(semaphore_t *s);
-// volatile bool try_down(semaphore_t *s);
-
// up
// 只会唤醒进程,但不会立即重新调度进程
volatile void up(semaphore_t *s);
#include <processor.h>
#include <system.h>
#include <types.h>
-#include <wait.h>
+// #include <wait.h>
enum {
TASK_UNUSED,
#include <irq.h>
#include <list.h>
-
+#include <sched.h>
union task_union;
typedef struct wait_queue_head {
#endif
void irq_bh_handler();
+void schedule();
__attribute__((regparm(1))) void irq_handler(pt_regs_t *regs) {
unsigned int irq = regs->irq;