UbixOS  2.0
ubthread.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2002-2018 The UbixOS Project.
3  * All rights reserved.
4  *
5  * This was developed by Christopher W. Olsen for the UbixOS Project.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted
8  * provided that the following conditions are met:
9  *
10  * 1) Redistributions of source code must retain the above copyright notice, this list of
11  * conditions, the following disclaimer and the list of authors.
12  * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13  * conditions, the following disclaimer and the list of authors in the documentation and/or
14  * other materials provided with the distribution.
15  * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16  * endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef _UBTHREAD_H
30 #define _UBTHREAD_H
31 
32 #include <sys/types.h>
33 #include <ubixos/sched.h>
34 #include <ubixos/time.h>
35 
36 #define LOCKED 1
37 #define UNLOCKED 0
38 
39 typedef struct ubthread *ubthread_t;
42 
43 struct ubthread {
44  struct taskStruct *task;
45 };
46 
47 struct ubthread_cond {
48  int id;
49  bool lock;
50 };
51 
53  int id;
54  bool lock;
56 };
57 
58 struct ubthread_list {
61 };
62 
66 };
67 
71 };
72 
73 struct taskStruct *ubthread_self();
74 int ubthread_cond_init(ubthread_cond_t *cond, const uInt32 attr);
78 int ubthread_create(struct taskStruct **thread, const uInt32 *attr, void (*tproc)(void), void *arg);
81 int ubthread_cond_timedwait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, const struct timespec *abstime);
85 
86 #endif
taskStruct
Definition: sched.h:62
ubthread_cond_list::cond
ubthread_cond_t * cond
Definition: ubthread.h:65
ubthread_mutex
Definition: ubthread.h:52
uInt32
unsigned long int uInt32
Definition: objgfx30.h:49
ubthread_list
Definition: ubthread.h:58
ubthread_mutex::id
int id
Definition: ubthread.h:53
ubthread_cond_wait
int ubthread_cond_wait(ubthread_cond_t *cond, ubthread_mutex_t *mutex)
Definition: ubthread.c:148
ubthread_self
struct taskStruct * ubthread_self()
Definition: ubthread.c:45
ubthread_cond_list::next
struct ubthread_cond_list * next
Definition: ubthread.h:64
ubthread_cond_destroy
int ubthread_cond_destroy(ubthread_cond_t *cond)
Definition: ubthread.c:71
ubthread_mutex_list
Definition: ubthread.h:68
ubthread_mutex_t
struct ubthread_mutex * ubthread_mutex_t
Definition: ubthread.h:41
thread
Definition: thread.h:40
ubthread::task
struct taskStruct * task
Definition: ubthread.h:44
ubthread_mutex_list::next
struct ubthread_mutex_list * next
Definition: ubthread.h:69
sched.h
types.h
ubthread_mutex_init
int ubthread_mutex_init(ubthread_mutex_t *mutex, const uInt32 attr)
ubthread_cond::id
int id
Definition: ubthread.h:48
ubthread_cond_t
struct ubthread_cond * ubthread_cond_t
Definition: ubthread.h:40
ubthread_mutex_unlock
int ubthread_mutex_unlock(ubthread_mutex_t *mutex)
Definition: ubthread.c:109
ubthread_mutex_lock
int ubthread_mutex_lock(ubthread_mutex_t *mutex)
Definition: ubthread.c:88
ubthread_cond_signal
int ubthread_cond_signal(ubthread_cond_t *cond)
Definition: ubthread.c:157
mutex
struct ubthread_mutex_list * mutex
Definition: ubthread.c:43
time.h
ubthread_cond_timedwait
int ubthread_cond_timedwait(ubthread_cond_t *cond, ubthread_mutex_t *mutex, const struct timespec *abstime)
Definition: ubthread.c:129
ubthread_mutex_list::mutex
ubthread_mutex_t * mutex
Definition: ubthread.h:70
ubthread_list::next
struct ubthread_list * next
Definition: ubthread.h:59
ubthread_cond_list
Definition: ubthread.h:63
ubthread_mutex::lock
bool lock
Definition: ubthread.h:54
pidType
int pidType
Definition: types.h:75
ubthread_list::thread
ubthread_t thread
Definition: ubthread.h:60
ubthread_cond_broadcast
int ubthread_cond_broadcast(ubthread_cond_t *cond)
Definition: ubthread.c:164
ubthread_mutex_destroy
int ubthread_mutex_destroy(ubthread_mutex_t *mutex)
Definition: ubthread.c:77
ubthread_cond_init
int ubthread_cond_init(ubthread_cond_t *cond, const uInt32 attr)
ubthread_cond
Definition: ubthread.h:47
ubthread_mutex::pid
pidType pid
Definition: ubthread.h:55
ubthread_cond::lock
bool lock
Definition: ubthread.h:49
timespec
Definition: _timespec.h:11
ubthread
Definition: ubthread.h:43
ubthread_t
struct ubthread * ubthread_t
Definition: ubthread.h:39
ubthread_create
int ubthread_create(struct taskStruct **thread, const uInt32 *attr, void(*tproc)(void), void *arg)
Definition: ubthread.c:83