Changeset 38d8849 in mainline
- Timestamp:
- 2018-07-16T15:58:51Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- db51219f
- Parents:
- c124c985
- git-author:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-14 16:53:46)
- git-committer:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-16 15:58:51)
- Location:
- uspace
- Files:
-
- 1 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/rcubench/rcubench.c
rc124c985 r38d8849 40 40 #include <mem.h> 41 41 #include <errno.h> 42 #include <thread.h>43 42 #include <assert.h> 44 43 #include <async.h> … … 105 104 } 106 105 107 static voidthread_func(void *arg)106 static errno_t thread_func(void *arg) 108 107 { 109 108 bench_t *bench = (bench_t *)arg; … … 113 112 /* Signal another thread completed. */ 114 113 futex_up(&bench->done_threads); 114 return EOK; 115 115 } 116 116 … … 123 123 } 124 124 125 fibril_test_spawn_runners(bench->nthreads - 1); 126 125 127 /* Create and run the first nthreads - 1 threads.*/ 126 128 for (size_t k = 1; k < bench->nthreads; ++k) { 127 thread_id_t tid; 128 /* Also sets up a fibril for the thread. */ 129 errno_t ret = thread_create(thread_func, bench, "rcubench-t", &tid); 130 if (ret != EOK) { 129 fid_t f = fibril_create(thread_func, bench); 130 if (!f) { 131 131 printf("Error: Failed to create benchmark thread.\n"); 132 132 abort(); 133 133 } 134 thread_detach(tid); 134 fibril_detach(f); 135 fibril_add_ready(f); 135 136 } 136 137 -
uspace/app/rcutest/rcutest.c
rc124c985 r38d8849 41 41 #include <mem.h> 42 42 #include <errno.h> 43 #include <thread.h>44 43 #include <assert.h> 45 44 #include <async.h> … … 759 758 /*--------------------------------------------------------------------*/ 760 759 761 static FIBRIL_MUTEX_INITIALIZE(blocking_mtx);762 763 static void dummy_fibril(void *arg)764 {765 /* Block on an already locked mutex - enters the fibril manager. */766 fibril_mutex_lock(&blocking_mtx);767 assert(false);768 }769 770 760 static bool create_threads(size_t cnt) 771 761 { 772 762 /* Sanity check. */ 773 763 assert(cnt < 1024); 774 775 /* Keep this mutex locked so that dummy fibrils never exit. */ 776 bool success = fibril_mutex_trylock(&blocking_mtx); 777 assert(success); 778 779 for (size_t k = 0; k < cnt; ++k) { 780 thread_id_t tid; 781 782 errno_t ret = thread_create(dummy_fibril, NULL, "urcu-test-worker", &tid); 783 if (EOK != ret) { 784 printf("Failed to create thread '%zu' (error: %s)\n", k + 1, str_error_name(ret)); 785 return false; 786 } 787 } 788 764 fibril_test_spawn_runners(cnt); 789 765 return true; 790 766 } -
uspace/app/tester/float/float1.c
rc124c985 r38d8849 33 33 #include <stddef.h> 34 34 #include <atomic.h> 35 #include <thread.h> 35 #include <fibril.h> 36 #include <fibril_synch.h> 36 37 #include <inttypes.h> 37 38 #include "../tester.h" … … 43 44 #define PRECISION 100000000 44 45 45 static atomic_t threads_finished;46 static FIBRIL_SEMAPHORE_INITIALIZE(threads_finished, 0); 46 47 static atomic_t threads_fault; 47 48 48 static voide(void *data)49 static errno_t e(void *data) 49 50 { 50 51 for (unsigned int i = 0; i < ATTEMPTS; i++) { … … 64 65 } 65 66 66 atomic_inc(&threads_finished); 67 fibril_semaphore_up(&threads_finished); 68 return EOK; 67 69 } 68 70 … … 71 73 atomic_count_t total = 0; 72 74 73 atomic_set(&threads_finished, 0);74 75 atomic_set(&threads_fault, 0); 76 fibril_test_spawn_runners(THREADS); 75 77 76 78 TPRINTF("Creating threads"); 77 79 for (unsigned int i = 0; i < THREADS; i++) { 78 if (thread_create(e, NULL, "e", NULL) != EOK) { 80 fid_t f = fibril_create(e, NULL); 81 if (!f) { 79 82 TPRINTF("\nCould not create thread %u\n", i); 80 83 break; 81 84 } 85 fibril_detach(f); 86 fibril_add_ready(f); 82 87 83 88 TPRINTF("."); … … 87 92 TPRINTF("\n"); 88 93 89 while (atomic_get(&threads_finished) < total) { 90 TPRINTF("Threads left: %" PRIua "\n", 91 total - atomic_get(&threads_finished)); 92 thread_sleep(1); 94 for (unsigned int i = 0; i < total; i++) { 95 TPRINTF("Threads left: %" PRIua "\n", total - i); 96 fibril_semaphore_down(&threads_finished); 93 97 } 94 98 -
uspace/app/tester/thread/thread1.c
rc124c985 r38d8849 33 33 #include <atomic.h> 34 34 #include <errno.h> 35 #include <thread.h> 35 #include <fibril.h> 36 #include <fibril_synch.h> 36 37 #include <stdio.h> 37 38 #include <stddef.h> … … 40 41 41 42 static atomic_t finish; 42 static atomic_t threads_finished;43 43 44 static void threadtest(void *data) 44 static FIBRIL_SEMAPHORE_INITIALIZE(threads_finished, 0); 45 46 static errno_t threadtest(void *data) 45 47 { 46 thread_detach(thread_get_id());48 fibril_detach(fibril_get_id()); 47 49 48 50 while (atomic_get(&finish)) 49 thread_usleep(100000);51 fibril_usleep(100000); 50 52 51 atomic_inc(&threads_finished); 53 fibril_semaphore_up(&threads_finished); 54 return EOK; 52 55 } 53 56 … … 58 61 59 62 atomic_set(&finish, 1); 60 atomic_set(&threads_finished, 0); 63 64 fibril_test_spawn_runners(THREADS); 61 65 62 66 TPRINTF("Creating threads"); 63 67 for (i = 0; i < THREADS; i++) { 64 if (thread_create(threadtest, NULL, "threadtest", NULL) != EOK) { 68 fid_t f = fibril_create(threadtest, NULL); 69 if (!f) { 65 70 TPRINTF("\nCould not create thread %u\n", i); 66 71 break; 67 72 } 73 fibril_add_ready(f); 68 74 TPRINTF("."); 69 75 total++; … … 71 77 72 78 TPRINTF("\nRunning threads for %u seconds...", DELAY); 73 thread_sleep(DELAY);79 fibril_sleep(DELAY); 74 80 TPRINTF("\n"); 75 81 76 82 atomic_set(&finish, 0); 77 while (atomic_get(&threads_finished) < total) {83 for (i = 0; i < total; i++) { 78 84 TPRINTF("Threads left: %" PRIua "\n", 79 total - atomic_get(&threads_finished));80 thread_sleep(1);85 total - i); 86 fibril_semaphore_down(&threads_finished); 81 87 } 82 88 -
uspace/lib/c/arch/arm32/include/libarch/fibril.h
rc124c985 r38d8849 39 39 #include <types/common.h> 40 40 #include <align.h> 41 #include <thread.h>42 41 #include <libarch/fibril_context.h> 43 42 -
uspace/lib/c/generic/fibril.c
rc124c985 r38d8849 36 36 #include <adt/list.h> 37 37 #include <fibril.h> 38 #include <thread.h>39 38 #include <stack.h> 40 39 #include <tls.h> … … 49 48 #include <async.h> 50 49 50 #include "private/thread.h" 51 51 #include "private/fibril.h" 52 52 -
uspace/lib/c/generic/private/thread.h
rc124c985 r38d8849 36 36 #define LIBC_PRIVATE_THREAD_H_ 37 37 38 #include <time.h> 38 39 #include <abi/proc/uarg.h> 40 #include <libarch/thread.h> 41 #include <abi/proc/thread.h> 39 42 40 43 extern void __thread_entry(void); 41 44 extern void __thread_main(uspace_arg_t *); 45 46 extern errno_t thread_create(void (*)(void *), void *, const char *, thread_id_t *); 47 extern void thread_exit(int) __attribute__((noreturn)); 48 extern void thread_detach(thread_id_t); 49 extern thread_id_t thread_get_id(void); 50 extern int thread_usleep(useconds_t); 51 extern unsigned int thread_sleep(unsigned int); 42 52 43 53 #endif -
uspace/lib/c/generic/rcu.c
rc124c985 r38d8849 80 80 #include <assert.h> 81 81 #include <time.h> 82 #include <thread.h>83 82 84 83 #include "private/fibril.h" -
uspace/lib/c/generic/stats.c
rc124c985 r38d8849 184 184 } 185 185 186 /** Get single thread statistics187 *188 * @param thread_id Thread ID we are interested in.189 *190 * @return Pointer to the stats_thread_t structure.191 * If non-NULL then it should be eventually freed192 * by free().193 *194 */195 stats_thread_t *stats_get_thread(thread_id_t thread_id)196 {197 char name[SYSINFO_STATS_MAX_PATH];198 snprintf(name, SYSINFO_STATS_MAX_PATH, "system.threads.%" PRIu64, thread_id);199 200 size_t size = 0;201 stats_thread_t *stats_thread =202 (stats_thread_t *) sysinfo_get_data(name, &size);203 204 if (size != sizeof(stats_thread_t)) {205 if (stats_thread != NULL)206 free(stats_thread);207 return NULL;208 }209 210 return stats_thread;211 }212 213 186 /** Get exception statistics. 214 187 * -
uspace/lib/c/generic/thread.c
rc124c985 r38d8849 33 33 */ 34 34 35 #include <thread.h>36 35 #include <libc.h> 37 36 #include <stdbool.h> … … 159 158 } 160 159 161 /** Join thread.162 *163 * Currently not implemented.164 *165 * @param thread TID.166 *167 * @return Thread exit status.168 */169 errno_t thread_join(thread_id_t thread)170 {171 return 0;172 }173 174 160 /** Get current thread ID. 175 161 * -
uspace/lib/c/include/stats.h
rc124c985 r38d8849 37 37 38 38 #include <task.h> 39 #include <thread.h>40 39 #include <stdint.h> 41 40 #include <stdbool.h> … … 53 52 54 53 extern stats_thread_t *stats_get_threads(size_t *); 55 extern stats_thread_t *stats_get_thread(thread_id_t);56 54 57 55 extern stats_exc_t *stats_get_exceptions(size_t *); -
uspace/lib/pcut/tests/timeout.c
rc124c985 r38d8849 30 30 31 31 #ifdef __helenos__ 32 #include < thread.h>32 #include <fibril.h> 33 33 #else 34 34 #ifdef __unix … … 46 46 { 47 47 #ifdef __helenos__ 48 thread_sleep(sec);48 fibril_sleep(sec); 49 49 #else 50 50 #ifdef __unix -
uspace/lib/posix/include/posix/pthread.h
rc124c985 r38d8849 33 33 #define POSIX_PTHREAD_H_ 34 34 35 #include "libc/thread.h"36 35 #include "time.h" 37 36 38 typedef thread_id_tpthread_t;37 typedef void *pthread_t; 39 38 40 39 typedef struct { -
uspace/lib/posix/src/pthread/threads.c
rc124c985 r38d8849 36 36 #include "errno.h" 37 37 #include "posix/stdlib.h" 38 #include "libc/thread.h"38 #include <fibril.h> 39 39 #include "../internal/common.h" 40 40 41 41 pthread_t pthread_self(void) 42 42 { 43 return thread_get_id();43 return (pthread_t) fibril_get_id(); 44 44 } 45 45 -
uspace/lib/posix/src/unistd.c
rc124c985 r38d8849 45 45 46 46 #include "libc/task.h" 47 #include "libc/thread.h"48 47 #include "libc/stats.h" 49 48 #include "libc/malloc.h" … … 70 69 unsigned int sleep(unsigned int seconds) 71 70 { 72 return thread_sleep(seconds); 71 fibril_sleep(seconds); 72 return 0; 73 73 } 74 74
Note:
See TracChangeset
for help on using the changeset viewer.