ubthread.h

Go to the documentation of this file.
00001 /*****************************************************************************************
00002  Copyright (c) 2002-2004 The UbixOS Project
00003  All rights reserved.
00004 
00005  Redistribution and use in source and binary forms, with or without modification, are
00006  permitted provided that the following conditions are met:
00007 
00008  Redistributions of source code must retain the above copyright notice, this list of
00009  conditions, the following disclaimer and the list of authors.  Redistributions in binary
00010  form must reproduce the above copyright notice, this list of conditions, the following
00011  disclaimer and the list of authors in the documentation and/or other materials provided
00012  with the distribution. Neither the name of the UbixOS Project nor the names of its
00013  contributors may be used to endorse or promote products derived from this software
00014  without specific prior written permission.
00015 
00016  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
00017  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00018  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
00019  THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00020  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00021  OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00022  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
00023  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00024  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00025 
00026  $Id: ubthread_8h-source.html 88 2016-01-12 00:11:29Z reddawg $
00027 
00028 *****************************************************************************************/
00029 
00030 #ifndef _UBTHREAD_H
00031 #define _UBTHREAD_H
00032 
00033 #include <ubixos/types.h>
00034 #include <ubixos/sched.h>
00035 #include <ubixos/time.h>
00036 
00037 #define ETIMEDOUT -1
00038 
00039 #define LOCKED     1
00040 #define UNLOCKED   0
00041 
00042 typedef struct ubthread       *ubthread_t;
00043 typedef struct ubthread_cond  *ubthread_cond_t;
00044 typedef struct ubthread_mutex *ubthread_mutex_t;
00045 
00046 struct ubthread {
00047   kTask_t *task;
00048   };
00049 
00050 struct ubthread_cond {
00051   int   id;
00052   uInt8 locked;
00053   };
00054 
00055 struct ubthread_mutex {
00056   int     id;
00057   uInt8   locked;
00058   pidType pid;
00059   };
00060 
00061 struct ubthread_list {
00062   struct ubthread_list *next;
00063   ubthread_t           thread;
00064   };
00065 
00066 struct ubthread_cond_list {
00067   struct ubthread_cond_list *next;
00068   ubthread_cond_t           *cond;
00069   };
00070 
00071 struct ubthread_mutex_list {
00072   struct ubthread_mutex_list *next;
00073   ubthread_mutex_t           *mutex;
00074   };
00075 
00076 
00077 kTask_t *ubthread_self();
00078 int ubthread_cond_init(ubthread_cond_t *cond,const uInt32 attr);
00079 int ubthread_mutex_init(ubthread_mutex_t *mutex,const uInt32 attr);
00080 int ubthread_cond_destroy(ubthread_cond_t *cond);
00081 int ubthread_mutex_destroy(ubthread_mutex_t *mutex);
00082 int ubthread_create(kTask_t **thread,const uInt32 *attr,void (* tproc)(void), void *arg);
00083 int ubthread_mutex_lock(ubthread_mutex_t *mutex);
00084 int ubthread_mutex_unlock(ubthread_mutex_t *mutex);
00085 int ubthread_cond_timedwait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, const struct timespec *abstime);
00086 int ubthread_cond_wait(ubthread_cond_t *cond, ubthread_mutex_t *mutex);
00087 int ubthread_cond_signal(ubthread_cond_t *cond);
00088 
00089 #endif
00090 
00091 /***
00092  $Log: ubthread_8h-source.html,v $
00092  Revision 1.7  2006/12/15 17:47:08  reddawg
00092  Updates
00092 
00093  Revision 1.1.1.1  2006/06/01 12:46:14  reddawg
00094  ubix2
00095 
00096  Revision 1.2  2005/10/12 00:13:37  reddawg
00097  Removed
00098 
00099  Revision 1.1.1.1  2005/09/26 17:23:57  reddawg
00100  no message
00101 
00102  Revision 1.3  2004/09/07 20:58:35  reddawg
00103  time to roll back i can't think straight by friday
00104 
00105  Revision 1.2  2004/05/21 15:20:00  reddawg
00106  Cleaned up
00107 
00108 
00109  END
00110  ***/

Generated on Fri Dec 15 11:18:55 2006 for UbixOS V2 by  doxygen 1.4.7