diff --git a/user/tasks/examples/fifo-ex.c b/user/tasks/examples/fifo-ex.c index aa824481..7718bc66 100644 --- a/user/tasks/examples/fifo-ex.c +++ b/user/tasks/examples/fifo-ex.c @@ -10,7 +10,7 @@ #include "uart.h" -#define TEST_STR "fifo: hello world\n\r" +#define TEST_STR "[fifo example] hello world\n\r" #define LEN strlen(TEST_STR) void fifo_task1(void) diff --git a/user/tasks/examples/mqueue-ex.c b/user/tasks/examples/mqueue-ex.c index 59104303..e718e39a 100644 --- a/user/tasks/examples/mqueue-ex.c +++ b/user/tasks/examples/mqueue-ex.c @@ -16,7 +16,7 @@ void message_queue_task1(void) { setprogname("mqueue-ex-1"); - char *str = "mqueue: greeting"; + char *str = "greeting!"; struct mq_attr attr = { .mq_maxmsg = 100, @@ -56,7 +56,8 @@ void message_queue_task2(void) mq_receive(mqdes_print, str, MSG_SIZE_MAX, &msg_prio); /* Print received message */ - printf("received message \"%s\", priority = %d\n\r", str, msg_prio); + printf("[mqueue example] received \"%s\" with priority %d\n\r", str, + msg_prio); } } diff --git a/user/tasks/examples/mutex-ex.c b/user/tasks/examples/mutex-ex.c index c3615da3..8182026a 100644 --- a/user/tasks/examples/mutex-ex.c +++ b/user/tasks/examples/mutex-ex.c @@ -36,13 +36,13 @@ void mutex_task1(void) pthread_mutex_lock(&mutex); if (my_cnt == BUFFER_SIZE) { - printf("[task 1] buffer is full. producer is waiting...\n\r"); + printf("[mutex task 1] buffer is full, wait for consumer\n\r"); pthread_cond_wait(&cond_producer, &mutex); } /* Produce an item and add it to the buffer */ my_buffer[my_cnt++] = item; - printf("[task 1] produced item %d\n\r", item); + printf("[mutex task 1] produced item %d\n\r", item); item++; /* Signal to consumers that an item is available */ @@ -65,13 +65,13 @@ void mutex_task2(void) pthread_mutex_lock(&mutex); if (my_cnt == 0) { - printf("[task 2] buffer is empty. consumer is waiting...\n\r"); + printf("[mutex task 2] buffer is empty, wait for producer\n\r"); pthread_cond_wait(&cond_consumer, &mutex); } /* Consume an item from the buffer */ int item = my_buffer[--my_cnt]; - printf("[task 2] consumed item %d\n\r", item); + printf("[mutex task 2] consumed item %d\n\r", item); /* Signal to producers that there is space in the buffer */ pthread_cond_signal(&cond_producer); diff --git a/user/tasks/examples/poll-ex.c b/user/tasks/examples/poll-ex.c index ac3a1719..e2662a6d 100644 --- a/user/tasks/examples/poll-ex.c +++ b/user/tasks/examples/poll-ex.c @@ -53,7 +53,7 @@ void poll_task2(void) ssize_t rbytes = read(fifo_fd, buffer, sizeof(buffer) - 1); buffer[rbytes] = '\0'; - printf("received %d bytes\n\r", rbytes); + printf("[poll example] %d bytes is read from the fifo\n\r", rbytes); fds[0].revents = 0; } diff --git a/user/tasks/examples/priority-inversion.c b/user/tasks/examples/priority-inversion.c index f5eca2e7..fcac338a 100644 --- a/user/tasks/examples/priority-inversion.c +++ b/user/tasks/examples/priority-inversion.c @@ -26,7 +26,7 @@ void mutex_task_high(void) #endif pthread_mutex_init(&mutex, &attr); - printf("[mutex high] attempt to lock the mutex in 5 seconds.\n\r"); + printf("[mutex task high] attempt to lock the mutex in 5 seconds\n\r"); sleep(5); @@ -35,8 +35,8 @@ void mutex_task_high(void) pthread_mutex_lock(&mutex); printf( - "[mutex high] highest-priority thread locked the mutex " - "successfully.\n\r"); + "[mutex task high] mutex is locked by the highest-priority " + "thread\n\r"); /* End the critical section */ pthread_mutex_unlock(&mutex); @@ -53,12 +53,15 @@ void mutex_task_median(void) struct timespec start_time, curr_time; /* Occupy the CPU to block the lowest-prioiry thread after 3 seconds */ - printf("[mutex median] block the lowest-priority thread in 3 seconds.\n\r"); + printf( + "[mutex task median] block the lowest-priority thread in 3 " + "seconds\n\r"); sleep(3); /* Occupy the CPU for 10 seconds */ printf( - "[mutex median] block the lowest-priority thread for 10 seconds.\n\r"); + "[mutex task median] block the lowest-priority thread for 10 " + "seconds\n\r"); clock_gettime(CLOCK_MONOTONIC, &start_time); @@ -84,8 +87,8 @@ void mutex_task_low(void) pthread_mutex_lock(&mutex); printf( - "[mutex low] lowest-priority thread locked the mutex " - "successfully.\n\r"); + "[mutex task low] mutex is locked by the lowest-priority " + "thread\n\r"); /* Simulate some works */ sleep(2); diff --git a/user/tasks/examples/pthread-ex.c b/user/tasks/examples/pthread-ex.c index 4f686c65..78dc78cb 100644 --- a/user/tasks/examples/pthread-ex.c +++ b/user/tasks/examples/pthread-ex.c @@ -11,7 +11,7 @@ void *my_thread(void *arg) { for (int i = 0; i < 10; i++) { - printf("hello new thread.\n\r"); + printf("[pthread example] printing from the new thread\n\r"); sleep(1); } @@ -23,8 +23,8 @@ void pthread_task(void) setprogname("pthread-ex"); printf( - "a new thread will be created and" - " canceled after 10 seconds.\n\r"); + "[pthread example] a new thread will be created and" + " canceled after 10 seconds\n\r"); pthread_attr_t attr; struct sched_param param; diff --git a/user/tasks/examples/semaphore.c b/user/tasks/examples/semaphore.c index 795e6bb9..2c85d9d1 100644 --- a/user/tasks/examples/semaphore.c +++ b/user/tasks/examples/semaphore.c @@ -15,7 +15,7 @@ void semaphore_task1(void) while (1) { sleep(1); sem_post(&sem_print); - printf("[semaphore 1] posted semaphore.\n\r"); + printf("[semaphore task 1] semaphore increased\n\r"); } } @@ -25,7 +25,7 @@ void semaphore_task2(void) while (1) { sem_wait(&sem_print); - printf("[semaphore 2] received semaphore.\n\r"); + printf("[semaphore task 2] semaphore decreased\n\r"); } } diff --git a/user/tasks/examples/signal-ex.c b/user/tasks/examples/signal-ex.c index a0340ae9..d2b925c3 100644 --- a/user/tasks/examples/signal-ex.c +++ b/user/tasks/examples/signal-ex.c @@ -12,7 +12,7 @@ static int task1_pid; void sig_handler(int signum) { - printf("received signal %d.\n\r", signum); + printf("[SIGUSR1 handler] signal number is %d\n\r", signum); } void signal_task1(void) @@ -36,7 +36,7 @@ void signal_task1(void) sigwait(&set, &sig); /* Print after the signal arrived */ - printf("signal %d is captured.\n\r", sig); + printf("[signal example] signal %d is captured\n\r", sig); /* Sleep */ while (1) { diff --git a/user/tasks/examples/timer-ex.c b/user/tasks/examples/timer-ex.c index 13a65e3a..7d7158c5 100644 --- a/user/tasks/examples/timer-ex.c +++ b/user/tasks/examples/timer-ex.c @@ -11,7 +11,7 @@ void timer_callback(union sigval sv) { - printf("timer: time's up.\n\r"); + printf("[timer handler] time's up!\n\r"); } void timer_task(void)