////////////phase 4 void MsgSndISR(int msg_addr) { int msg_q_id; int freed_pid; msg_t *incoming_msg_ptr, *dst_msg_ptr; incoming_msg_ptr = (msg_t *) msg_addr; msg_q_id = incoming_msg_ptr->recipient; incoming_msg_ptr->OS_clock = OS_clock; incoming_msg_ptr->sender = running_pid; if(msg_q[msg_q_id].wait_q.len == 0) { MsgEnQ(incoming_msg_ptr, &msg_q[msg_q_id]); } else { freed_pid = DeQ(&(msg_q[msg_q_id].wait_q)); EnQ(freed_pid, &ready_q); pcb[freed_pid].state = READY; dst_msg_ptr = (msg_t *) pcb[freed_pid].TF_ptr->eax; *dst_msg_ptr = *incoming_msg_ptr; } }
void MsgSndISR() { int mid, pid; msg_t *src, *dest; mid = pcbs[cur_pid].tf_p->eax; src = (msg_t *)pcbs[cur_pid].tf_p->ebx; src->sender = cur_pid; // authenticate sender src->time_stamp = sys_tick; // authenticate time_stamp if(EmptyQ(&mboxes[mid].wait_q)) { MsgEnQ( src, &( mboxes[mid].msg_q ) ); } else { pid = DeQ(&mboxes[mid].wait_q); pcbs[pid].state = READY; EnQ(pid, &ready_q); dest = (msg_t *)pcbs[pid].tf_p->eax; // eax since MsgRcv changed *dest = *src; } }
void MsgSndISR(int mid, msg_t *p) { int pid; p->sender = cur_pid; p->send_tick = sys_tick; if(EmptyQ(&(mboxes[mid].wait_q))) // If wait Queue of message is empty. MsgEnQ(p, &(mboxes[mid].msg_q)); // Queue the message. else { pid = DeQ(&(mboxes[mid].wait_q)); // Dequeue the waiting process pcbs[pid].state = READY; EnQ(pid, &ready_q); *((msg_t *) pcbs[pid].tf_p->eax) = *p; } }
void MsgSndISR(int msg_addr) { msg_t *incoming_msg_ptr, *destination; int msg_q_id, freed_pid; incoming_msg_ptr = (msg_t *)msg_addr; msg_q_id = incoming_msg_ptr->recipient; //authenticate send and os_clock of msg incoming_msg_ptr->OS_clock = OS_clock; incoming_msg_ptr->sender = running_pid; if (msg_q[msg_q_id].wait_q.len <1) { MsgEnQ(incoming_msg_ptr, &msg_q[msg_q_id]); }else { freed_pid = DeQ(&msg_q[msg_q_id].wait_q); pcb[freed_pid].state= READY; EnQ(freed_pid, &ready_q); destination = (msg_t*)pcb[freed_pid].TF_ptr->eax; *destination = *incoming_msg_ptr; } }