From 2d1303763e6650416a636ca16a0e9ab7529106cd Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Sun, 27 Oct 2013 08:13:27 +0100 Subject: [PATCH 1/5] fix spelling in msg.c --- core/msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/msg.c b/core/msg.c index 9ae2b9adf4..09fd56f4a7 100644 --- a/core/msg.c +++ b/core/msg.c @@ -250,11 +250,11 @@ static int _msg_receive(msg_t *m, int block) return 1; } else { - DEBUG("%s: msg_receive(): Wakeing up waiting thread.\n", active_thread->name); + DEBUG("%s: msg_receive(): Waking up waiting thread.\n", active_thread->name); tcb_t *sender = (tcb_t*) node->data; if (n >= 0) { - /* we've already got a messgage from the queue. as there is a + /* We've already got a message from the queue. As there is a * waiter, take it's message into the just freed queue space. */ m = &(me->msg_array[cib_put(&(me->msg_queue))]); From 5e6cc92291c8fb314a14aafec5e0a3ce91aca6cf Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Sun, 27 Oct 2013 08:37:18 +0100 Subject: [PATCH 2/5] harmonize msg.c DEBUG statements Use same order (function: [thread_name:] message) throughout msg.c. Begin message with a capital letter. --- core/msg.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/core/msg.c b/core/msg.c index 09fd56f4a7..20bdf732e8 100644 --- a/core/msg.c +++ b/core/msg.c @@ -74,17 +74,17 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block) } if (!block) { - DEBUG("%s: receiver not waiting. block=%u\n", active_thread->name, block); + DEBUG("msg_send: %s: Receiver not waiting, block=%u\n", active_thread->name, block); eINT(); return 0; } - DEBUG("%s: send_blocked.\n", active_thread->name); + DEBUG("msg_send: %s: send_blocked.\n", active_thread->name); queue_node_t n; n.priority = active_thread->priority; n.data = (unsigned int) active_thread; n.next = NULL; - DEBUG("%s: Adding node to msg_waiters:\n", active_thread->name); + DEBUG("msg_send: %s: Adding node to msg_waiters:\n", active_thread->name); queue_priority_add(&(target->msg_waiters), &n); @@ -101,10 +101,10 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block) sched_set_status((tcb_t*) active_thread, newstatus); - DEBUG("%s: back from send block.\n", active_thread->name); + DEBUG("msg_send: %s: Back from send block.\n", active_thread->name); } else { - DEBUG("%s: direct msg copy.\n", active_thread->name); + DEBUG("msg_send: %s: Direct msg copy.\n", active_thread->name); /* copy msg to target */ msg_t *target_message = (msg_t*) target->wait_data; *target_message = *m; @@ -122,7 +122,7 @@ int msg_send_int(msg_t *m, unsigned int target_pid) tcb_t *target = (tcb_t *) sched_threads[target_pid]; if (target->status == STATUS_RECEIVE_BLOCKED) { - DEBUG("msg_send_int: direct msg copy from %i to %i.\n", thread_getpid(), target_pid); + DEBUG("msg_send_int: Direct msg copy from %i to %i.\n", thread_getpid(), target_pid); m->sender_pid = target_pid; @@ -135,7 +135,7 @@ int msg_send_int(msg_t *m, unsigned int target_pid) return 1; } else { - DEBUG("msg_send_int: receiver not waiting.\n"); + DEBUG("msg_send_int: Receiver not waiting.\n"); return (queue_msg(target, m)); } } @@ -159,17 +159,17 @@ int msg_reply(msg_t *m, msg_t *reply) tcb_t *target = (tcb_t*) sched_threads[m->sender_pid]; if (!target) { - DEBUG("msg_reply(): target \"%" PRIu16 "\" not existing...dropping msg!\n", m->sender_pid); + DEBUG("msg_reply(): %s: Target \"%" PRIu16 "\" not existing...dropping msg!\n", active_thread->name, m->sender_pid); return -1; } if (target->status != STATUS_REPLY_BLOCKED) { - DEBUG("%s: msg_reply(): target \"%s\" not waiting for reply.", active_thread->name, target->name); + DEBUG("msg_reply(): %s: Target \"%s\" not waiting for reply.", active_thread->name, target->name); restoreIRQ(state); return -1; } - DEBUG("%s: msg_reply(): direct msg copy.\n", active_thread->name); + DEBUG("msg_reply(): %s: Direct msg copy.\n", active_thread->name); /* copy msg to target */ msg_t *target_message = (msg_t*) target->wait_data; *target_message = *reply; @@ -185,7 +185,7 @@ int msg_reply_int(msg_t *m, msg_t *reply) tcb_t *target = (tcb_t*) sched_threads[m->sender_pid]; if (target->status != STATUS_REPLY_BLOCKED) { - DEBUG("%s: msg_reply_int(): target \"%s\" not waiting for reply.", active_thread->name, target->name); + DEBUG("msg_reply_int(): %s: Target \"%s\" not waiting for reply.", active_thread->name, target->name); return -1; } @@ -209,7 +209,7 @@ int msg_receive(msg_t *m) static int _msg_receive(msg_t *m, int block) { dINT(); - DEBUG("%s: msg_receive.\n", active_thread->name); + DEBUG("_msg_receive: %s: _msg_receive.\n", active_thread->name); tcb_t *me = (tcb_t*) sched_threads[thread_pid]; @@ -225,7 +225,7 @@ static int _msg_receive(msg_t *m, int block) } if (n >= 0) { - DEBUG("%s: msg_receive(): We've got a queued message.\n", active_thread->name); + DEBUG("_msg_receive: %s: _msg_receive(): We've got a queued message.\n", active_thread->name); *m = me->msg_array[n]; } else { @@ -235,10 +235,10 @@ static int _msg_receive(msg_t *m, int block) queue_node_t *node = queue_remove_head(&(me->msg_waiters)); if (node == NULL) { - DEBUG("%s: msg_receive(): No thread in waiting list.\n", active_thread->name); + DEBUG("_msg_receive: %s: _msg_receive(): No thread in waiting list.\n", active_thread->name); if (n < 0) { - DEBUG("%s: msg_receive(): No msg in queue. Going blocked.\n", active_thread->name); + DEBUG("_msg_receive(): %s: No msg in queue. Going blocked.\n", active_thread->name); sched_set_status(me, STATUS_RECEIVE_BLOCKED); eINT(); @@ -250,7 +250,7 @@ static int _msg_receive(msg_t *m, int block) return 1; } else { - DEBUG("%s: msg_receive(): Waking up waiting thread.\n", active_thread->name); + DEBUG("_msg_receive: %s: _msg_receive(): Waking up waiting thread.\n", active_thread->name); tcb_t *sender = (tcb_t*) node->data; if (n >= 0) { From f1b89df8d8c76a11747fc076298bf38b0d73cc4f Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Mon, 28 Oct 2013 12:54:16 +0100 Subject: [PATCH 3/5] explain the "brainfuck condition" --- core/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/msg.c b/core/msg.c index 20bdf732e8..8201153896 100644 --- a/core/msg.c +++ b/core/msg.c @@ -275,7 +275,7 @@ static int _msg_receive(msg_t *m, int block) int msg_init_queue(msg_t *array, int num) { - /* make sure brainfuck condition is met */ + /* check if num is a power of two by comparing to its complement */ if (num && (num & (num - 1)) == 0) { tcb_t *me = (tcb_t*) active_thread; me->msg_array = array; From 37c9b8ebfde2c2f4cc9406a03789551cee3a7e87 Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Mon, 28 Oct 2013 12:55:11 +0100 Subject: [PATCH 4/5] fix spelling in msg.h --- core/include/msg.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/include/msg.h b/core/include/msg.h index 78db899b43..8723b29e26 100644 --- a/core/include/msg.h +++ b/core/include/msg.h @@ -59,7 +59,7 @@ typedef struct msg { * @param block If true and receiver is not receive-blocked, function will block. If not, function * returns. * - * @return 1 if sending was successfull (message delivered directly or to a queue) + * @return 1 if sending was successful (message delivered directly or to a queue) * @return 0 if receiver is not waiting or has a full message queue and block == false * @return -1 on error (invalid PID) */ @@ -74,7 +74,7 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block); * @param m pointer to message structure * @param target_pid PID of target thread * - * @return 1 if sending was successfull + * @return 1 if sending was successful * @return 0 if receiver is not waiting and block == false */ int msg_send_int(msg_t *m, unsigned int target_pid); @@ -120,8 +120,8 @@ int msg_send_receive(msg_t *m, msg_t *reply, unsigned int target_pid); * @param m msg to reply to. * @param reply message that target will get as reply * - * @return 1 if succcessful - * qreturn 0 on error + * @return 1 if successful + * @return 0 on error */ int msg_reply(msg_t *m, msg_t *reply); From 4b02701ad0d5df45f970166777685b3fa43002ad Mon Sep 17 00:00:00 2001 From: Ludwig Ortmann Date: Mon, 28 Oct 2013 12:55:29 +0100 Subject: [PATCH 5/5] document msg_init_queue return values --- core/include/msg.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/include/msg.h b/core/include/msg.h index 8723b29e26..0d96e30036 100644 --- a/core/include/msg.h +++ b/core/include/msg.h @@ -130,6 +130,9 @@ int msg_reply(msg_t *m, msg_t *reply); * * @param array Pointer to preallocated array of msg objects * @param num Number of msg objects in array. MUST BE POWER OF TWO! + * + * @return 0 if successful + * @return -1 on error */ int msg_init_queue(msg_t *array, int num);