Changeset 25390
- Timestamp:
- 05/08/08 20:36:49 (3 days ago)
- Files:
-
- haiku/trunk/headers/posix/pthread.h (modified) (1 diff)
- haiku/trunk/src/system/libroot/posix/pthread/Jamfile (modified) (1 diff)
- haiku/trunk/src/system/libroot/posix/pthread/pthread_attr.c (modified) (4 diffs)
- haiku/trunk/src/system/libroot/posix/pthread/pthread.c (modified) (4 diffs)
- haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
haiku/trunk/headers/posix/pthread.h
r25090 r25390 171 171 int *detachstate); 172 172 extern int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate); 173 extern int pthread_attr_getstacksize(const pthread_attr_t *attr, 174 size_t *stacksize); 175 extern int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize); 176 177 #if 0 /* Unimplemented attribute functions: */ 178 179 // mandatory! 180 extern int pthread_attr_getschedparam(const pthread_attr_t *attr, 181 struct sched_param *param); 182 extern int pthread_attr_setschedparam(pthread_attr_t *attr, 183 const struct sched_param *param); 184 185 // [TPS] 186 extern int pthread_attr_getinheritsched(const pthread_attr_t *attr, 187 int *inheritsched); 188 extern int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched); 189 190 extern int pthread_attr_getschedpolicy(const pthread_attr_t *attr, 191 int *policy); 192 extern int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy); 193 extern int pthread_attr_getscope(const pthread_attr_t *attr, 194 int *contentionscope); 195 extern int pthread_attr_setscope(pthread_attr_t *attr, int contentionscope); 196 197 // [XSI] 198 extern int pthread_attr_getguardsize(const pthread_attr_t *attr, 199 size_t *guardsize); 200 extern int pthread_attr_setguardsize(pthread_attr_t *attr, size_t guardsize); 201 202 // [TSA] 203 extern int pthread_attr_getstackaddr(const pthread_attr_t *attr, 204 void **stackaddr); 205 extern int pthread_attr_setstackaddr(pthread_attr_t *attr, void *stackaddr); 206 207 // [TSA TSS] 208 extern int pthread_attr_getstack(const pthread_attr_t *attr, 209 void **stackaddr, size_t *stacksize); 210 extern int pthread_attr_setstack(pthread_attr_t *attr, void *stackaddr, size_t stacksize); 211 212 #endif /* 0 */ 213 173 214 174 215 /* thread functions */ haiku/trunk/src/system/libroot/posix/pthread/Jamfile
r25000 r25390 1 1 SubDir HAIKU_TOP src system libroot posix pthread ; 2 2 3 UsePrivateKernelHeaders ; 3 4 UsePrivateHeaders libroot ; 4 5 haiku/trunk/src/system/libroot/posix/pthread/pthread_attr.c
r17885 r25390 1 1 /* 2 ** Copyright 2006, Jérôme Duval. All rights reserved.3 ** Distributed under the terms of the MIT License.4 */ 5 2 * Copyright 2008, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2006, Jérôme Duval. All rights reserved. 4 * Distributed under the terms of the MIT License. 5 */ 6 6 7 7 #include <pthread.h> … … 9 9 10 10 #include <stdlib.h> 11 12 #include <kernel.h> 11 13 12 14 … … 25 27 attr->detach_state = PTHREAD_CREATE_JOINABLE; 26 28 attr->sched_priority = B_NORMAL_PRIORITY; 29 attr->stack_size = USER_STACK_SIZE; 27 30 28 31 *_attr = attr; … … 76 79 } 77 80 81 82 int 83 pthread_attr_getstacksize(const pthread_attr_t *_attr, size_t *stacksize) 84 { 85 pthread_attr *attr; 86 87 if (_attr == NULL || (attr = *_attr) == NULL || stacksize == NULL) 88 return B_BAD_VALUE; 89 90 *stacksize = attr->stack_size; 91 92 return 0; 93 } 94 95 96 int 97 pthread_attr_setstacksize(pthread_attr_t *_attr, size_t stacksize) 98 { 99 pthread_attr *attr; 100 101 if (_attr == NULL || (attr = *_attr) == NULL) 102 return B_BAD_VALUE; 103 104 if (stacksize < MIN_USER_STACK_SIZE || stacksize > MAX_USER_STACK_SIZE) 105 return B_BAD_VALUE; 106 107 attr->stack_size = stacksize; 108 109 return 0; 110 } haiku/trunk/src/system/libroot/posix/pthread/pthread.c
r25000 r25390 12 12 #include <TLS.h> 13 13 14 #include <kernel.h> 15 #include <syscalls.h> 16 #include <thread.h> 17 14 18 15 19 static const pthread_attr pthread_attr_default = { 16 20 PTHREAD_CREATE_JOINABLE, 17 B_NORMAL_PRIORITY 21 B_NORMAL_PRIORITY, 22 USER_STACK_SIZE 18 23 }; 19 24 … … 61 66 62 67 static int32 63 pthread_thread_entry( void *_thread)68 pthread_thread_entry(thread_func _unused, void *_thread) 64 69 { 65 70 struct pthread_thread *thread = (struct pthread_thread *)_thread; … … 85 90 struct pthread_thread *thread; 86 91 thread_id threadID; 92 struct thread_creation_attributes attributes; 87 93 88 94 if (_thread == NULL) … … 110 116 } 111 117 112 threadID = spawn_thread(pthread_thread_entry, "pthread func", 113 attr->sched_priority, thread); 118 attributes.entry = pthread_thread_entry; 119 attributes.name = "pthread func"; 120 attributes.priority = attr->sched_priority; 121 attributes.args1 = thread; 122 attributes.args2 = NULL; 123 attributes.stack_address = NULL; 124 attributes.stack_size = attr->stack_size; 125 126 threadID = _kern_spawn_thread(&attributes); 114 127 if (threadID < B_OK) { 115 128 // stupid error code (EAGAIN) but demanded by POSIX haiku/trunk/src/system/libroot/posix/pthread/pthread_private.h
r25000 r25390 45 45 int32 detach_state; 46 46 int32 sched_priority; 47 size_t stack_size; 47 48 } pthread_attr; 48 49
