1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

core: adapt to msg_try_send

This commit is contained in:
Kaspar Schleiser 2014-10-20 16:49:40 +02:00
parent bdcac07faa
commit 5146c66786
26 changed files with 46 additions and 42 deletions

View File

@ -158,7 +158,7 @@ static void SMB380_simple_interrupthandler(void)
if (interruptTicksSMB380 >= sampleRateSMB380 - 1) {
interruptTicksSMB380 = 0;
wakeupmessage.type = MSG_TYPE_SMB380_WAKEUP;
msg_send(&wakeupmessage, simple_pid, 0);
msg_try_send(&wakeupmessage, simple_pid);
}
else {
interruptTicksSMB380++;
@ -566,7 +566,7 @@ void wakeUpRegisteredProcesses(void)
while ((pointerNo < SMB380_RING_BUFF_MAX_THREADS) &&
(PointerList[pointerNo] > 0)) {
msg_send(&wakeupmessage, PointerList[pointerNo], false);
msg_try_send(&wakeupmessage, PointerList[pointerNo]);
pointerNo++;
}
}

View File

@ -199,7 +199,7 @@ int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid)
/* msg_send blocks until reply received */
return msg_send(m, target_pid, true);
return msg_send(m, target_pid);
}
int msg_reply(msg_t *m, msg_t *reply)

View File

@ -138,7 +138,7 @@ static void riot_ccn_relay_config(int argc, char **argv)
msg_t m;
m.content.value = atoi(argv[1]);
m.type = CCNL_RIOT_CONFIG_CACHE;
msg_send(&m, _relay_pid, 1);
msg_send(&m, _relay_pid);
}
static void riot_ccn_transceiver_start(kernel_pid_t _relay_pid)
@ -195,7 +195,7 @@ static void riot_ccn_relay_stop(int argc, char **argv)
msg_t m;
m.content.value = 0;
m.type = CCNL_RIOT_HALT;
msg_send(&m, _relay_pid, 1);
msg_send(&m, _relay_pid);
/* mark relay as not running */
_relay_pid = 0;
@ -240,7 +240,7 @@ static void riot_ccn_pit_test(int argc, char **argv)
m.content.ptr = (char *) &rmsg;
m.type = CCNL_RIOT_MSG;
msg_send(&m, _relay_pid, 1);
msg_send(&m, _relay_pid);
if ((segment % 50) == 0) {
vtimer_now(&now);
@ -289,7 +289,7 @@ static void riot_ccn_populate(int argc, char **argv)
msg_t m;
m.content.value = 0;
m.type = CCNL_RIOT_POPULATE;
msg_send(&m, _relay_pid, 1);
msg_send(&m, _relay_pid);
}
static void riot_ccn_stat(int argc, char **argv)
@ -300,7 +300,7 @@ static void riot_ccn_stat(int argc, char **argv)
msg_t m;
m.content.value = 0;
m.type = CCNL_RIOT_PRINT_STAT;
msg_send(&m, _relay_pid, 1);
msg_send(&m, _relay_pid);
}
static const shell_command_t sc[] = {

View File

@ -58,7 +58,7 @@ void populate_cache(void)
msg_t m;
m.content.value = 0;
m.type = CCNL_RIOT_POPULATE;
msg_send(&m, _relay_pid, 1);
msg_send(&m, _relay_pid);
}
void *second_thread(void *arg)

View File

@ -138,7 +138,7 @@ void rpl_udp_ignore(int argc, char **argv)
if (argc == 2) {
a = atoi(argv[1]);
printf("sending to transceiver (%" PRIkernel_pid "): %u\n", transceiver_pid, (*(uint8_t *)tcmd.data));
msg_send(&mesg, transceiver_pid, 1);
msg_send(&mesg, transceiver_pid);
}
else {
printf("Usage: %s <addr>\n", argv[0]);

View File

@ -52,7 +52,7 @@ static int appserver_sent_content(uint8_t *buf, int len, kernel_pid_t from)
m.content.ptr = (char *) &rmsg;
kernel_pid_t dest_pid = from;
DEBUGMSG(1, "sending msg to pid=%" PRIkernel_pid "\n", dest_pid);
int ret = msg_send(&m, dest_pid, 1);
int ret = msg_send(&m, dest_pid);
DEBUGMSG(1, "msg_reply returned: %d\n", ret);
return ret;
}

View File

@ -95,7 +95,7 @@ int riot_send_msg(uint8_t *buf, uint16_t size, uint16_t to)
m.type = CCNL_RIOT_MSG;
m.content.ptr = (char *) rmsg;
DEBUGMSG(1, "sending msg to pid=%" PRIkernel_pid "\n", to);
msg_send(&m, to, 1);
msg_send(&m, to);
return size;
}
@ -105,7 +105,7 @@ void riot_send_nack(uint16_t to)
msg_t m;
m.type = CCNL_RIOT_NACK;
DEBUGMSG(1, "sending NACK msg to pid=%" PRIkernel_pid"\n", to);
msg_send(&m, to, 0);
msg_try_send(&m, to);
}
void *ccnl_riot_relay_helper_start(void *);

View File

@ -67,7 +67,7 @@ int ccnl_riot_client_get(kernel_pid_t relay_pid, char *name, char *reply_buf)
msg_t m, rep;
m.content.ptr = (char *) &rmsg;
m.type = CCNL_RIOT_MSG;
msg_send(&m, relay_pid, 1);
msg_send(&m, relay_pid);
/* ######################################################################### */
@ -131,7 +131,7 @@ int ccnl_riot_client_new_face(kernel_pid_t relay_pid, char *type, char *faceid,
m.content.ptr = (char *) &rmsg;
m.type = CCNL_RIOT_MSG;
DEBUGMSG(1, " sending face req to relay\n");
msg_send(&m, relay_pid, 1);
msg_send(&m, relay_pid);
/* ######################################################################### */
@ -160,7 +160,7 @@ int ccnl_riot_client_register_prefix(kernel_pid_t relay_pid, char *prefix, char
m.content.ptr = (char *) &rmsg;
m.type = CCNL_RIOT_MSG;
DEBUGMSG(1, " sending prefix req to relay\n");
msg_send(&m, relay_pid, 1);
msg_send(&m, relay_pid);
/* ######################################################################### */

View File

@ -113,7 +113,7 @@ void serial_reader_f(void)
if (conf_packet->conftype == BORDER_CONF_SYN) {
m.content.ptr = (char *)conf_packet;
msg_send(&m, main_pid, 1);
msg_send(&m, main_pid);
continue;
}
}

View File

@ -43,7 +43,7 @@ ipv6_addr_t init_threeway_handshake(void)
border_syn_packet_t *syn;
msg_t m;
m.content.ptr = NULL;
msg_send(&m, border_get_serial_reader(), 1);
msg_send(&m, border_get_serial_reader());
msg_receive(&m);
syn = (border_syn_packet_t *)m.content.ptr;

View File

@ -262,7 +262,7 @@ int icmpv6_demultiplex(const icmpv6_hdr_t *hdr)
if (_rpl_process_pid != KERNEL_PID_UNDEF) {
msg_t m_send;
m_send.content.ptr = (char *) &hdr->code;
msg_send(&m_send, _rpl_process_pid, 1);
msg_send(&m_send, _rpl_process_pid);
}
else {
DEBUG("INFO: no RPL handler registered\n");
@ -371,7 +371,7 @@ void *ipv6_process(void *arg)
msg_t m_send;
m_send.type = IPV6_PACKET_RECEIVED;
m_send.content.ptr = (char *) ipv6_buf;
msg_send(&m_send, sixlowip_reg[i], 1);
msg_send(&m_send, sixlowip_reg[i]);
}
}

View File

@ -795,7 +795,7 @@ void lowpan_read(uint8_t *data, uint8_t length, net_if_eui64_t *s_addr,
current_frame.length = length;
current_frame.data = data;
m_send.content.ptr = (char *) &current_frame;
msg_send(&m_send, sixlowpan_reg[i], 1);
msg_send(&m_send, sixlowpan_reg[i]);
}
}

View File

@ -43,7 +43,11 @@ int socket_base_net_msg_reply(msg_t *m, msg_t *reply, uint16_t message)
int socket_base_net_msg_send(msg_t *m, kernel_pid_t pid, bool block, uint16_t message)
{
m->type = message;
return msg_send(m, pid, block);
if (block) {
return msg_send(m, pid);
} else {
return msg_try_send(m, pid);
}
}
int socket_base_net_msg_send_recv(msg_t *m, msg_t *reply, kernel_pid_t pid, uint16_t message)

View File

@ -477,12 +477,12 @@ void handle_tcp_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
if (tcp_socket->socket_values.tcp_control.state == TCP_LAST_ACK) {
uint8_t target_pid = tcp_socket->recv_pid;
memset(tcp_socket, 0, sizeof(socket_internal_t));
msg_send(&m_send_tcp, target_pid, 0);
msg_try_send(&m_send_tcp, target_pid);
return;
}
else if (tcp_socket->socket_values.tcp_control.state == TCP_CLOSING) {
msg_send(&m_send_tcp, tcp_socket->recv_pid, 0);
msg_send(&m_send_tcp, tcp_socket->send_pid, 0);
msg_try_send(&m_send_tcp, tcp_socket->recv_pid);
msg_try_send(&m_send_tcp, tcp_socket->send_pid);
return;
}
else if (get_waiting_connection_socket(tcp_socket->socket_id, ipv6_header,
@ -613,8 +613,8 @@ void handle_tcp_fin_ack_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,
send_tcp(tcp_socket, current_tcp_packet, temp_ipv6_header, TCP_ACK, 0);
msg_send(&m_send, tcp_socket->send_pid, 0);
msg_send(&m_send, tcp_socket->recv_pid, 0);
msg_try_send(&m_send, tcp_socket->send_pid);
msg_try_send(&m_send, tcp_socket->recv_pid);
}
void handle_tcp_no_flags_packet(ipv6_hdr_t *ipv6_header, tcp_hdr_t *tcp_header,

View File

@ -285,7 +285,7 @@ void _transceiver_monitor_handler(int argc, char **argv)
mesg.content.ptr = (char *) &tcmd;
mesg.type = SET_MONITOR;
msg_send(&mesg, transceiver_pid, 1);
msg_send(&mesg, transceiver_pid);
}
/* checked for type safety */

View File

@ -503,7 +503,7 @@ static void receive_packet(uint16_t type, uint8_t pos)
m.content.ptr = (char *) &(transceiver_buffer[transceiver_buffer_pos]);
DEBUG("transceiver: Notify thread %" PRIkernel_pid "\n", reg[i].pid);
if (msg_send(&m, reg[i].pid, false) && (m.type != ENOBUFFER)) {
if (msg_try_send(&m, reg[i].pid) && (m.type != ENOBUFFER)) {
transceiver_buffer[transceiver_buffer_pos].processing++;
}
else {

View File

@ -124,7 +124,7 @@ void sender(void)
snd_buffer[1] = i & 0x00FF;
p.data = snd_buffer;
i++;
msg_send(&mesg, transceiver_pid, 1);
msg_send(&mesg, transceiver_pid);
hwtimer_wait(HWTIMER_TICKS(SENDING_DELAY));
}
}

View File

@ -61,7 +61,7 @@ void rx(void *ptr, char data)
ringbuffer_add_one(&rx_buf, data);
if (data == '\n') {
msg_send(&msg, main_pid, 1);
msg_send(&msg, main_pid);
}
}

View File

@ -42,7 +42,7 @@ static void *child_fun(void *arg)
msg_t m;
m.type = i + 1;
m.content.ptr = (void *) sched_active_thread->name;
msg_send(&m, parent_pid, true);
msg_send(&m, parent_pid);
}
printf("End of %s.\n", sched_active_thread->name);

View File

@ -50,7 +50,7 @@ void *run(void *arg)
msg_t final;
final.content.value = me;
int err = msg_send(&final, main_id, 1);
int err = msg_send(&final, main_id);
if (err < 0) {
printf("[!!!] Failed to send message from %d to main\n", me);
@ -79,7 +79,7 @@ int main(void)
else {
args[i].content.value = i + 1;
int err = msg_send(&args[i], ths[i], 1);
int err = msg_send(&args[i], ths[i]);
if (err < 0) {
printf("[!!!] Sending message to thread %d failed\n", ths[i]);
}

View File

@ -76,7 +76,7 @@ void *thread3(void *arg)
msg_t msg;
msg.content.value = i;
printf("T3 i=%d\n", i);
msg_send(&msg, p1, 1);
msg_send(&msg, p1);
}
return NULL;
}

View File

@ -39,7 +39,7 @@ void *thread1(void *arg)
memset(&msg, 1, sizeof(msg_t));
/* step 1: send asynchonously */
msg_send(&msg, p_main, 0);
msg_try_send(&msg, p_main);
/* step 2: send message, turning its status into STATUS_REPLY_BLOCKED */
msg_send_receive(&msg, &reply, p_main);

View File

@ -39,7 +39,7 @@ void *thread1(void *arg)
memset(&msg, 1, sizeof(msg_t));
/* step 1: send asynchonously */
msg_send(&msg, p_main, 0);
msg_try_send(&msg, p_main);
/* step 2: send message, turning its status into STATUS_REPLY_BLOCKED */
msg_send_receive(&msg, &reply, p_main);

View File

@ -43,7 +43,7 @@ void *sub_thread(void *arg)
msg.content.ptr = (char*)thread_getname(pid);
msg_send(&msg, p_main, true);
msg_send(&msg, p_main);
printf("THREAD %s (pid:%" PRIkernel_pid ") end.\n", thread_getname(pid), pid);

View File

@ -103,11 +103,11 @@ int main(void)
puts("sending 1st msg");
m.content.ptr = (char *) &msg_a;
msg_send(&m, pid, false);
msg_try_send(&m, pid);
puts("sending 2nd msg");
m.content.ptr = (char *) &msg_b;
msg_send(&m, pid, false);
msg_try_send(&m, pid);
kernel_pid_t pid2 = thread_create(
timer_stack_local,
@ -122,6 +122,6 @@ int main(void)
while (1) {
vtimer_sleep(sleep);
msg_send(&m, pid2, 0);
msg_try_send(&m, pid2);
}
}

View File

@ -115,7 +115,7 @@ int main(void)
for (unsigned i = 0; i < sizeof(timer_msgs)/sizeof(struct timer_msg); i++) {
printf("Sending timer msg %u...\n", i);
m.content.ptr = (char *) &timer_msgs[i];
msg_send(&m, pid, false);
msg_try_send(&m, pid);
}
return 0;