⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 synch.h

📁 GEEKOS是一个免费的操作系统内核
💻 H
字号:
/* * Synchronization primitives * Copyright (c) 2001, David H. Hovemeyer <daveho@cs.umd.edu> * $Revision: 1.13 $ *  * This is free software.  You are permitted to use, * redistribute, and modify it as specified in the file "COPYING". */#ifndef GEEKOS_SYNCH_H#define GEEKOS_SYNCH_H#include <geekos/kthread.h>/* * mutex states */enum { MUTEX_UNLOCKED, MUTEX_LOCKED };struct Mutex {    int state;    struct Kernel_Thread* owner;    struct Thread_Queue waitQueue;};#define MUTEX_INITIALIZER { MUTEX_UNLOCKED, 0, THREAD_QUEUE_INITIALIZER }struct Condition {    struct Thread_Queue waitQueue;};void Mutex_Init(struct Mutex* mutex);void Mutex_Lock(struct Mutex* mutex);void Mutex_Unlock(struct Mutex* mutex);void Cond_Init(struct Condition* cond);void Cond_Wait(struct Condition* cond, struct Mutex* mutex);void Cond_Signal(struct Condition* cond);void Cond_Broadcast(struct Condition* cond);#define IS_HELD(mutex) \    ((mutex)->state == MUTEX_LOCKED && (mutex)->owner == g_currentThread)#endif  /* GEEKOS_SYNCH_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -