Changeset 38d8849 in mainline for uspace/app/tester


Ignore:
Timestamp:
2018-07-16T15:58:51Z (7 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
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)
Message:

Privatize <thread.h>.

Location:
uspace/app/tester
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/float/float1.c

    rc124c985 r38d8849  
    3333#include <stddef.h>
    3434#include <atomic.h>
    35 #include <thread.h>
     35#include <fibril.h>
     36#include <fibril_synch.h>
    3637#include <inttypes.h>
    3738#include "../tester.h"
     
    4344#define PRECISION  100000000
    4445
    45 static atomic_t threads_finished;
     46static FIBRIL_SEMAPHORE_INITIALIZE(threads_finished, 0);
    4647static atomic_t threads_fault;
    4748
    48 static void e(void *data)
     49static errno_t e(void *data)
    4950{
    5051        for (unsigned int i = 0; i < ATTEMPTS; i++) {
     
    6465        }
    6566
    66         atomic_inc(&threads_finished);
     67        fibril_semaphore_up(&threads_finished);
     68        return EOK;
    6769}
    6870
     
    7173        atomic_count_t total = 0;
    7274
    73         atomic_set(&threads_finished, 0);
    7475        atomic_set(&threads_fault, 0);
     76        fibril_test_spawn_runners(THREADS);
    7577
    7678        TPRINTF("Creating threads");
    7779        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) {
    7982                        TPRINTF("\nCould not create thread %u\n", i);
    8083                        break;
    8184                }
     85                fibril_detach(f);
     86                fibril_add_ready(f);
    8287
    8388                TPRINTF(".");
     
    8792        TPRINTF("\n");
    8893
    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);
    9397        }
    9498
  • uspace/app/tester/thread/thread1.c

    rc124c985 r38d8849  
    3333#include <atomic.h>
    3434#include <errno.h>
    35 #include <thread.h>
     35#include <fibril.h>
     36#include <fibril_synch.h>
    3637#include <stdio.h>
    3738#include <stddef.h>
     
    4041
    4142static atomic_t finish;
    42 static atomic_t threads_finished;
    4343
    44 static void threadtest(void *data)
     44static FIBRIL_SEMAPHORE_INITIALIZE(threads_finished, 0);
     45
     46static errno_t threadtest(void *data)
    4547{
    46         thread_detach(thread_get_id());
     48        fibril_detach(fibril_get_id());
    4749
    4850        while (atomic_get(&finish))
    49                 thread_usleep(100000);
     51                fibril_usleep(100000);
    5052
    51         atomic_inc(&threads_finished);
     53        fibril_semaphore_up(&threads_finished);
     54        return EOK;
    5255}
    5356
     
    5861
    5962        atomic_set(&finish, 1);
    60         atomic_set(&threads_finished, 0);
     63
     64        fibril_test_spawn_runners(THREADS);
    6165
    6266        TPRINTF("Creating threads");
    6367        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) {
    6570                        TPRINTF("\nCould not create thread %u\n", i);
    6671                        break;
    6772                }
     73                fibril_add_ready(f);
    6874                TPRINTF(".");
    6975                total++;
     
    7177
    7278        TPRINTF("\nRunning threads for %u seconds...", DELAY);
    73         thread_sleep(DELAY);
     79        fibril_sleep(DELAY);
    7480        TPRINTF("\n");
    7581
    7682        atomic_set(&finish, 0);
    77         while (atomic_get(&threads_finished) < total) {
     83        for (i = 0; i < total; i++) {
    7884                TPRINTF("Threads left: %" PRIua "\n",
    79                     total - atomic_get(&threads_finished));
    80                 thread_sleep(1);
     85                    total - i);
     86                fibril_semaphore_down(&threads_finished);
    8187        }
    8288
Note: See TracChangeset for help on using the changeset viewer.