Changeset 654a30a in mainline for uspace/app/trace/trace.c


Ignore:
Timestamp:
2009-07-21T19:50:40Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8e1dc00
Parents:
9d8a1ed
Message:

Make use of fibril sync primitives.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/trace/trace.c

    r9d8a1ed r654a30a  
    4747#include <io/console.h>
    4848#include <io/keycode.h>
     49#include <fibril_sync.h>
    4950
    5051#include <libc.h>
     
    7273uintptr_t thash;
    7374volatile int paused;
     75fibril_condvar_t paused_cv;
     76fibril_mutex_t paused_lock;
    7477
    7578void thread_trace_start(uintptr_t thread_hash);
     
    454457        while (!abort_trace) {
    455458
     459                fibril_mutex_lock(&paused_lock);
    456460                if (paused) {
    457                         printf("Press R to resume.\n");
    458                         while (paused) {
    459                                 async_usleep(1000000);
    460                         }
    461                         printf("Resumed\n");
     461                        printf("Thread [%d] paused. Press R to resume.\n",
     462                            thread_id);
     463
     464                        while (paused)
     465                                fibril_condvar_wait(&paused_cv, &paused_lock);
     466
     467                        printf("Thread [%d] resumed.\n", thread_id);
    462468                }
     469                fibril_mutex_unlock(&paused_lock);
    463470
    464471                /* Run thread until an event occurs */
     
    482489                        case UDEBUG_EVENT_STOP:
    483490                                printf("Stop event\n");
     491                                fibril_mutex_lock(&paused_lock);
     492                                paused = 1;
     493                                fibril_mutex_unlock(&paused_lock);
    484494                                break;
    485495                        case UDEBUG_EVENT_THREAD_B:
     
    599609                        printf("Pause...\n");
    600610                        rc = udebug_stop(phoneid, thash);
    601                         if (rc == EOK)
    602                                 paused = 1;
    603                         else
    604                                 printf("stop -> %d\n", rc);
     611                        if (rc != EOK)
     612                                printf("Error: stop -> %d\n", rc);
    605613                        break;
    606614                case KC_R:
     615                        fibril_mutex_lock(&paused_lock);
    607616                        paused = 0;
     617                        fibril_condvar_broadcast(&paused_cv);
     618                        fibril_mutex_unlock(&paused_lock);
    608619                        printf("Resume...\n");
    609620                        break;
     
    645656        next_thread_id = 1;
    646657        paused = 0;
     658        fibril_mutex_initialize(&paused_lock);
     659        fibril_condvar_initialize(&paused_cv);
    647660
    648661        proto_init();
Note: See TracChangeset for help on using the changeset viewer.