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

📄 pthread.h

📁 usoc在北京博创兴业有限公司的实验平台s3c2410上运行。 2. 各实验的全部源代码分别存放在各实验目录下面。
💻 H
📖 第 1 页 / 共 2 页
字号:
/** * \file pthread.h * \author Wei Yongming <ymwei@minigui.org> * \date 2003/02/03 *  * Description:   This header contains the pthread definitions needed to  *                support MiniGUI under uC/OS-II.  * \verbatim    Copyright (C) 2004 Feynman Software.    This file is part of MiniGUI, a lightweight Graphics User Interface     support library for real-time embedded Linux.    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.    This program 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 General Public License for more details.    You should have received a copy of the GNU General Public License    along with this program; if not, write to the Free Software    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA \endverbatim *//* * $Id: ucos2_pthread.h,v 1.2 2004/02/25 02:34:49 weiym Exp $ * *             MiniGUI for Linux, uClinux, eCos, and uC/OS-II version 1.5.x *             Copyright (C) 1998-2002 Wei Yongming. *             Copyright (C) 2002-2004 Feynman Software. */#ifndef UCOSII_PTHREAD_H#define UCOSII_PTHREAD_H#include "common.h"#ifdef __UCOSII__#include <stddef.h>//=============================================================================// Tunable macros#define NR_POSIX_PTHREAD_THREADS_MAX    16      // This can not be less than 5.#define HIGHEST_UCOSII_PTHREAD_PRIORITY 16#define LOWEST_UCOSII_PTHREAD_PRIORITY  (HIGHEST_UCOSII_PTHREAD_PRIORITY + NR_POSIX_PTHREAD_THREADS_MAX - 1)#undef PTHREAD_KEYS_MAX#define PTHREAD_KEYS_MAX                64#undef PTHREAD_STACK_MIN#define PTHREAD_STACK_MIN               (PTHREAD_KEYS_MAX * sizeof(void *) + 1024*8)#undef PTHREAD_DESTRUCTOR_ITERATIONS#define PTHREAD_DESTRUCTOR_ITERATIONS  4#define UCOSII_THREAD_LOWEST_PRIORITY   64//-----------------------------------------------------------------------------// Internal types#define pthread_t ucos2_pthread_t#define pthread_key_t ucos2_pthread_key_t#define pthread_once_t ucos2_pthread_once_t#define pthread_attr_t ucos2_pthread_attr_t#define pthread_mutex_t ucos2_pthread_mutex_t#define pthread_mutexattr_t ucos2_pthread_mutexattr_t//-----------------------------------------------------------------------------// Basic types.typedef unsigned int pthread_t;typedef int pthread_key_t;typedef int pthread_once_t;//-----------------------------------------------------------------------------// Scheduling parameters. At present only the priority is defined.struct sched_param{    int                 prio;};//-----------------------------------------------------------------------------// Thread attribute structure.typedef struct pthread_attr_t{    unsigned int        detachstate:2,#if 0 /* not support in uC/OS-II */                        scope:2,                        inheritsched:2,                        schedpolicy:2,#endif /* not support in uC/OS-II */                        stackaddr_valid:1,                        stacksize_valid:1;    struct sched_param  schedparam;    void                *stackaddr;    size_t              stacksize;} pthread_attr_t;// Values for detachstate#define PTHREAD_CREATE_JOINABLE	        1#define PTHREAD_CREATE_DETACHED	        2#if 0 /* not support in uC/OS-II */// Values for scope#define PTHREAD_SCOPE_SYSTEM            1#define PTHREAD_SCOPE_PROCESS           2// Values for inheritsched#define PTHREAD_INHERIT_SCHED           1#define PTHREAD_EXPLICIT_SCHED          2#endif /* not support in uC/OS-II *///=============================================================================// General thread operations//-----------------------------------------------------------------------------// Thread creation and management.// Create a thread.int pthread_create ( pthread_t *thread,                             const pthread_attr_t *attr,                             void *(*start_routine) (void *),                             void *arg);// Get current thread id.pthread_t pthread_self ( void );// Compare two thread identifiers.int pthread_equal (pthread_t thread1, pthread_t thread2);// Terminate current thread.void pthread_exit (void *retval);// Wait for the thread to terminate. If thread_return is not NULL then// the retval from the thread's call to pthread_exit() is stored at// *thread_return.int pthread_join (pthread_t thread, void **thread_return);// Set the detachstate of the thread to "detached". The thread then does not// need to be joined and its resources will be freed when it exits.int pthread_detach (pthread_t thread);#if 0 /* not support in uC/OS-II *///-----------------------------------------------------------------------------// Thread scheduling controls// Set scheduling policy and parameters for the threadint pthread_setschedparam (pthread_t thread,                                   int policy,                                   const struct sched_param *param);// Get scheduling policy and parameters for the threadint pthread_getschedparam (pthread_t thread,                                   int *policy,                                   struct sched_param *param);#endif /* not support in uC/OS-II *///-----------------------------------------------------------------------------// Thread attribute handling.// Initialize attributes object with default attributes:// detachstate          == PTHREAD_JOINABLE// scope                == PTHREAD_SCOPE_SYSTEM// inheritsched         == PTHREAD_EXPLICIT_SCHED// schedpolicy          == SCHED_OTHER// schedparam           == unset// stackaddr            == unset// stacksize            == 0// int pthread_attr_init (pthread_attr_t *attr);// Destroy thread attributes objectint pthread_attr_destroy (pthread_attr_t *attr);// Set the detachstate attributeint pthread_attr_setdetachstate (pthread_attr_t *attr,                                         int detachstate);// Get the detachstate attributeint pthread_attr_getdetachstate (const pthread_attr_t *attr,                                         int *detachstate);// Set scheduling contention scopeint pthread_attr_setscope (pthread_attr_t *attr, int scope);// Get scheduling contention scopeint pthread_attr_getscope (const pthread_attr_t *attr, int *scope);// Set scheduling inheritance attributeint pthread_attr_setinheritsched (pthread_attr_t *attr, int inherit);// Get scheduling inheritance attributeint pthread_attr_getinheritsched (const pthread_attr_t *attr,                                          int *inherit);// Set scheduling policyint pthread_attr_setschedpolicy (pthread_attr_t *attr, int policy);// Get scheduling policyint pthread_attr_getschedpolicy (const pthread_attr_t *attr,                                         int *policy);// Set scheduling parametersint pthread_attr_setschedparam (pthread_attr_t *attr,				        const struct sched_param *param);// Get scheduling parametersint pthread_attr_getschedparam (const pthread_attr_t *attr,                                        struct sched_param *param);// Set starting address of stack. Whether this is at the start or end of// the memory block allocated for the stack depends on whether the stack// grows up or down.int pthread_attr_setstackaddr (pthread_attr_t *attr, void *stackaddr);// Get any previously set stack address.int pthread_attr_getstackaddr (const pthread_attr_t *attr,                                       void **stackaddr);// Set minimum creation stack size.

⌨️ 快捷键说明

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