Merge pull request #275 from LudwigOrtmann/fix_msg_spelling

fix spelling and harmonize DEBUG statements in msg.[ch]
This commit is contained in:
Oleg Hahm 2013-10-28 15:17:09 -07:00
commit 07db2fd0b5
2 changed files with 25 additions and 22 deletions

View File

@ -59,7 +59,7 @@ typedef struct msg {
* @param block If true and receiver is not receive-blocked, function will block. If not, function * @param block If true and receiver is not receive-blocked, function will block. If not, function
* returns. * 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 0 if receiver is not waiting or has a full message queue and block == false
* @return -1 on error (invalid PID) * @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 m pointer to message structure
* @param target_pid PID of target thread * @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 * @return 0 if receiver is not waiting and block == false
*/ */
int msg_send_int(msg_t *m, unsigned int target_pid); 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 m msg to reply to.
* @param reply message that target will get as reply * @param reply message that target will get as reply
* *
* @return 1 if succcessful * @return 1 if successful
* qreturn 0 on error * @return 0 on error
*/ */
int msg_reply(msg_t *m, msg_t *reply); int msg_reply(msg_t *m, msg_t *reply);
@ -130,6 +130,9 @@ int msg_reply(msg_t *m, msg_t *reply);
* *
* @param array Pointer to preallocated array of msg objects * @param array Pointer to preallocated array of msg objects
* @param num Number of msg objects in array. MUST BE POWER OF TWO! * @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); int msg_init_queue(msg_t *array, int num);

View File

@ -74,17 +74,17 @@ int msg_send(msg_t *m, unsigned int target_pid, bool block)
} }
if (!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(); eINT();
return 0; return 0;
} }
DEBUG("%s: send_blocked.\n", active_thread->name); DEBUG("msg_send: %s: send_blocked.\n", active_thread->name);
queue_node_t n; queue_node_t n;
n.priority = active_thread->priority; n.priority = active_thread->priority;
n.data = (unsigned int) active_thread; n.data = (unsigned int) active_thread;
n.next = NULL; 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); 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); 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 { 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 */ /* copy msg to target */
msg_t *target_message = (msg_t*) target->wait_data; msg_t *target_message = (msg_t*) target->wait_data;
*target_message = *m; *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]; tcb_t *target = (tcb_t *) sched_threads[target_pid];
if (target->status == STATUS_RECEIVE_BLOCKED) { 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; m->sender_pid = target_pid;
@ -135,7 +135,7 @@ int msg_send_int(msg_t *m, unsigned int target_pid)
return 1; return 1;
} }
else { else {
DEBUG("msg_send_int: receiver not waiting.\n"); DEBUG("msg_send_int: Receiver not waiting.\n");
return (queue_msg(target, m)); 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]; tcb_t *target = (tcb_t*) sched_threads[m->sender_pid];
if (!target) { 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; return -1;
} }
if (target->status != STATUS_REPLY_BLOCKED) { 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); restoreIRQ(state);
return -1; 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 */ /* copy msg to target */
msg_t *target_message = (msg_t*) target->wait_data; msg_t *target_message = (msg_t*) target->wait_data;
*target_message = *reply; *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]; tcb_t *target = (tcb_t*) sched_threads[m->sender_pid];
if (target->status != STATUS_REPLY_BLOCKED) { 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; return -1;
} }
@ -209,7 +209,7 @@ int msg_receive(msg_t *m)
static int _msg_receive(msg_t *m, int block) static int _msg_receive(msg_t *m, int block)
{ {
dINT(); 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]; 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) { 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]; *m = me->msg_array[n];
} }
else { else {
@ -235,10 +235,10 @@ static int _msg_receive(msg_t *m, int block)
queue_node_t *node = queue_remove_head(&(me->msg_waiters)); queue_node_t *node = queue_remove_head(&(me->msg_waiters));
if (node == NULL) { 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) { 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); sched_set_status(me, STATUS_RECEIVE_BLOCKED);
eINT(); eINT();
@ -250,11 +250,11 @@ static int _msg_receive(msg_t *m, int block)
return 1; return 1;
} }
else { else {
DEBUG("%s: msg_receive(): Wakeing 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; tcb_t *sender = (tcb_t*) node->data;
if (n >= 0) { 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. * waiter, take it's message into the just freed queue space.
*/ */
m = &(me->msg_array[cib_put(&(me->msg_queue))]); m = &(me->msg_array[cib_put(&(me->msg_queue))]);
@ -275,7 +275,7 @@ static int _msg_receive(msg_t *m, int block)
int msg_init_queue(msg_t *array, int num) 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) { if (num && (num & (num - 1)) == 0) {
tcb_t *me = (tcb_t*) active_thread; tcb_t *me = (tcb_t*) active_thread;
me->msg_array = array; me->msg_array = array;