port_os.h

来自「在AVR单片机上使用的一款RTOS」· C头文件 代码 · 共 65 行

H
65
字号
/*
 *  iRTOS
 *  Copyright (C) 2008  Dmitriy Cherepanov
 *
 *  This file is part of iRTOS
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public either
 *  version 2.1 of the License, or (at your option) any later version.
 *  This source is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  Do not be lasy! Look http://irtos.sourceforge.net for the latest version.
 */

#ifndef _OS_PORT_FILE_H_
#define _OS_PORT_FILE_H_ 1
/** \file
 *\if russian_lng
 *	Glib
 *\else
 *	Glib
 *\endif
 */
#include "glib/gthread.h"
/** 
 *\if russian_lng
 *	Glib port enter/exit critical functions
 *\else
 *	Glib port enter/exit critical functions
 *\endif
 */
GStaticRecMutex kernel_recursive_mutex;



#define PORT_ENTER_CRITICAL_SECTION() 				\
		g_static_rec_mutex_lock(&kernel_recursive_mutex)

#define PORT_EXIT_CRITICAL_SECTION() 				\
		g_static_rec_mutex_unlock(&kernel_recursive_mutex)

/** 
 *\if russian_lng
 *	This 
 *\else
 *	it is a pity but we have to do use this functions then do
 *	context switching (in cooperative glib is only yeld function).
 *	In MCU and other arches it makes automaticly
 *\endif
 */
 
#define PORT_SAVE_CRITICAL_SECTION_DEPTH(depth_variable)	\
		depth_variable=g_static_rec_mutex_unlock_full(&kernel_recursive_mutex)

#define PORT_RESTORE_CRITICAL_SECTION_DEPTH(depth_variable)	\
		g_static_rec_mutex_lock_full(&kernel_recursive_mutex, depth_variable);




#endif	/* _OS_PORT_FILE_H_  */

⌨️ 快捷键说明

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