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

📄 mutex.c

📁 一个Windows下的Linux专用虚拟机
💻 C
字号:
/* * This source code is a part of coLinux source package. * * Dan Aloni <da-x@colinux.org>, 2003 (c) * * The code is licensed under the GPL. See the COPYING file at * the root directory. * */#include "../ddk.h"#include <colinux/os/alloc.h>#include <colinux/os/kernel/mutex.h>struct co_os_mutex {	KMUTEX mutex;};co_rc_t co_os_mutex_create(co_os_mutex_t *mutex_out){	co_os_mutex_t mutex;	*mutex_out = NULL;	mutex = co_os_malloc(sizeof(*mutex));	if (mutex == NULL)		return CO_RC(OUT_OF_MEMORY);	KeInitializeMutex(&mutex->mutex, 0);	*mutex_out = mutex;	return CO_RC(OK);}void co_os_mutex_acquire(co_os_mutex_t mutex){	NTSTATUS status;	status = KeWaitForMutexObject(&mutex->mutex, UserRequest, 				      KernelMode, FALSE, NULL);}void co_os_mutex_release(co_os_mutex_t mutex){	KeReleaseMutex(&mutex->mutex, FALSE);}void co_os_mutex_destroy(co_os_mutex_t mutex){	if (mutex != NULL) 		co_os_free(mutex);}

⌨️ 快捷键说明

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