Changeset 43114c5 in mainline for test


Ignore:
Timestamp:
2005-04-09T18:22:53Z (21 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8262010
Parents:
e6ba9a3f
Message:

Introduce macros CPU, THREAD, TASK and use them to replace the→cpu, the→thread, the→task.
Later on, this will make it possible to reference *current* cpu, thread and/or task without the aid from virtual memory.

Location:
test/synch
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • test/synch/rwlock2/test.c

    re6ba9a3f r43114c5  
    7575        rwlock_read_lock(&rwlock);     
    7676       
    77         thrd = thread_create(writer, NULL, the->task, 0);
     77        thrd = thread_create(writer, NULL, TASK, 0);
    7878        if (thrd)
    7979                thread_ready(thrd);
  • test/synch/rwlock3/test.c

    re6ba9a3f r43114c5  
    4545void reader(void *arg)
    4646{
    47         printf("cpu%d, tid %d: trying to lock rwlock for reading....\n", the->cpu->id, the->thread->tid);       
     47        printf("cpu%d, tid %d: trying to lock rwlock for reading....\n", CPU->id, THREAD->tid);         
    4848        rwlock_read_lock(&rwlock);
    4949        rwlock_read_unlock(&rwlock);   
    50         printf("cpu%d, tid %d: success\n", the->cpu->id, the->thread->tid);             
     50        printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);               
    5151
    52         printf("cpu%d, tid %d: trying to lock rwlock for writing....\n", the->cpu->id, the->thread->tid);       
     52        printf("cpu%d, tid %d: trying to lock rwlock for writing....\n", CPU->id, THREAD->tid);         
    5353
    5454        rwlock_write_lock(&rwlock);
    5555        rwlock_write_unlock(&rwlock);
    56         printf("cpu%d, tid %d: success\n", the->cpu->id, the->thread->tid);                     
     56        printf("cpu%d, tid %d: success\n", CPU->id, THREAD->tid);                       
    5757       
    5858        printf("Test passed.\n");       
     
    7878       
    7979        for (i=0; i<4; i++) {
    80                 thrd = thread_create(reader, NULL, the->task, 0);
     80                thrd = thread_create(reader, NULL, TASK, 0);
    8181                if (thrd)
    8282                        thread_ready(thrd);
  • test/synch/rwlock4/test.c

    re6ba9a3f r43114c5  
    7474
    7575        to = random(40000);
    76         printf("cpu%d, tid %d w+ (%d)\n", the->cpu->id, the->thread->tid, to);
     76        printf("cpu%d, tid %d w+ (%d)\n", CPU->id, THREAD->tid, to);
    7777        rc = rwlock_write_lock_timeout(&rwlock, to);
    7878        if (SYNCH_FAILED(rc)) {
    79                 printf("cpu%d, tid %d w!\n", the->cpu->id, the->thread->tid);
     79                printf("cpu%d, tid %d w!\n", CPU->id, THREAD->tid);
    8080                return;
    8181        };
    82         printf("cpu%d, tid %d w=\n", the->cpu->id, the->thread->tid);
     82        printf("cpu%d, tid %d w=\n", CPU->id, THREAD->tid);
    8383
    8484        if (rwlock.readers_in) panic("Oops.");
     
    8787
    8888        rwlock_write_unlock(&rwlock);
    89         printf("cpu%d, tid %d w-\n", the->cpu->id, the->thread->tid);   
     89        printf("cpu%d, tid %d w-\n", CPU->id, THREAD->tid);     
    9090}
    9191
     
    9696       
    9797        to = random(2000);
    98         printf("cpu%d, tid %d r+ (%d)\n", the->cpu->id, the->thread->tid, to);
     98        printf("cpu%d, tid %d r+ (%d)\n", CPU->id, THREAD->tid, to);
    9999        rc = rwlock_read_lock_timeout(&rwlock, to);
    100100        if (SYNCH_FAILED(rc)) {
    101                 printf("cpu%d, tid %d r!\n", the->cpu->id, the->thread->tid);
     101                printf("cpu%d, tid %d r!\n", CPU->id, THREAD->tid);
    102102                return;
    103103        }
    104         printf("cpu%d, tid %d r=\n", the->cpu->id, the->thread->tid);
     104        printf("cpu%d, tid %d r=\n", CPU->id, THREAD->tid);
    105105        thread_usleep(30000);
    106106        rwlock_read_unlock(&rwlock);
    107         printf("cpu%d, tid %d r-\n", the->cpu->id, the->thread->tid);           
     107        printf("cpu%d, tid %d r-\n", CPU->id, THREAD->tid);             
    108108}
    109109
     
    135135                printf("Creating %d readers\n", k);
    136136                for (i=0; i<k; i++) {
    137                         thrd = thread_create(reader, NULL, the->task, 0);
     137                        thrd = thread_create(reader, NULL, TASK, 0);
    138138                        if (thrd)
    139139                                thread_ready(thrd);
     
    145145                printf("Creating %d writers\n", k);
    146146                for (i=0; i<k; i++) {
    147                         thrd = thread_create(writer, NULL, the->task, 0);
     147                        thrd = thread_create(writer, NULL, TASK, 0);
    148148                        if (thrd)
    149149                                thread_ready(thrd);
  • test/synch/rwlock5/test.c

    re6ba9a3f r43114c5  
    9696                for (j=0; j<(READERS+WRITERS)/2; j++) {
    9797                        for (k=0; k<i; k++) {
    98                                 thrd = thread_create(reader, NULL, the->task, 0);
     98                                thrd = thread_create(reader, NULL, TASK, 0);
    9999                                if (thrd)
    100100                                        thread_ready(thrd);
     
    103103                        }
    104104                        for (k=0; k<(4-i); k++) {
    105                                 thrd = thread_create(writer, NULL, the->task, 0);
     105                                thrd = thread_create(writer, NULL, TASK, 0);
    106106                                if (thrd)
    107107                                        thread_ready(thrd);
  • test/synch/semaphore1/test.c

    re6ba9a3f r43114c5  
    100100                for (j=0; j<(CONSUMERS+PRODUCERS)/2; j++) {
    101101                        for (k=0; k<i; k++) {
    102                                 thrd = thread_create(consumer, NULL, the->task, 0);
     102                                thrd = thread_create(consumer, NULL, TASK, 0);
    103103                                if (thrd)
    104104                                        thread_ready(thrd);
     
    107107                        }
    108108                        for (k=0; k<(4-i); k++) {
    109                                 thrd = thread_create(producer, NULL, the->task, 0);
     109                                thrd = thread_create(producer, NULL, TASK, 0);
    110110                                if (thrd)
    111111                                        thread_ready(thrd);
  • test/synch/semaphore2/test.c

    re6ba9a3f r43114c5  
    7070       
    7171        to = random(20000);
    72         printf("cpu%d, tid %d down+ (%d)\n", the->cpu->id, the->thread->tid, to);
     72        printf("cpu%d, tid %d down+ (%d)\n", CPU->id, THREAD->tid, to);
    7373        rc = semaphore_down_timeout(&sem, to);
    7474        if (SYNCH_FAILED(rc)) {
    75                 printf("cpu%d, tid %d down!\n", the->cpu->id, the->thread->tid);
     75                printf("cpu%d, tid %d down!\n", CPU->id, THREAD->tid);
    7676                return;
    7777        }
    7878       
    79         printf("cpu%d, tid %d down=\n", the->cpu->id, the->thread->tid);       
     79        printf("cpu%d, tid %d down=\n", CPU->id, THREAD->tid); 
    8080        thread_usleep(random(30000));
    8181       
    8282        semaphore_up(&sem);
    83         printf("cpu%d, tid %d up\n", the->cpu->id, the->thread->tid);
     83        printf("cpu%d, tid %d up\n", CPU->id, THREAD->tid);
    8484}
    8585
     
    108108                printf("Creating %d consumers\n", k);
    109109                for (i=0; i<k; i++) {
    110                         thrd = thread_create(consumer, NULL, the->task, 0);
     110                        thrd = thread_create(consumer, NULL, TASK, 0);
    111111                        if (thrd)
    112112                                thread_ready(thrd);
Note: See TracChangeset for help on using the changeset viewer.