char *test_send_recv() { int i = 0; for(i = 0; i < NUM_TESTS; i++) { Queue_send(queue, tests[i]); mu_assert(Queue_peek(queue) == tests[0], "Wrong next value."); } mu_assert(Queue_count(queue) == NUM_TESTS, "Wrong count on send."); QUEUE_FOREACH(queue, cur) { debug("VAL: %s", (char *)cur->value); }
char *test_send_recv() { int i = 0; for(i = 0; i < NUM_TESTS; i++) { Queue_send(queue, tests[i]); mu_assert(Queue_peek(queue) == tests[0], "Wrong text value."); } mu_assert(Queue_count(queue) == 0, "Wrong count after recv."); return NULL; }
void CPU_dispatcher(CPU_p cpu, Interrupt_type interrupt_type) { // Save pointers to the previous and next process (needed so we can print) PCB_p prevProcess = cpu->currentProcess; PCB_p nextProcess = Queue_peek(cpu->readyQueue); if (CTX_SWITCH_COUNT % 4 == 0) { if (prevProcess != NULL) fprintf(file, "Running process: %s", PCB_toString(prevProcess)); if (nextProcess != NULL) fprintf(file, "Switching to: %s", PCB_toString(nextProcess)); } // 1. Save the state of current process into its PCB (PC value) // Per Canvas Discussions, DON'T DO THIS AGAIN HERE! It's in ISR. // 2. Then dequeue next waiting process if (!Queue_isEmpty(cpu->readyQueue)) cpu->currentProcess = Queue_dequeue(cpu->readyQueue); // 3. Change its state to running PCB_set_state(cpu->currentProcess, running); if (interrupt_type == timer) { // 4. Copy its PC value to sysStack, replacing the interrupted process CPU_push_sysStack(cpu, PCB_get_PC(cpu->currentProcess)); } else if (interrupt_type == normal) { CPU_set_pc(cpu, cpu->sysStack); } if (CTX_SWITCH_COUNT % 4 == 0) { if (prevProcess != NULL) fprintf(file, "Last Process: %s", PCB_toString(prevProcess)); if (nextProcess != NULL) fprintf(file, "Current running Process: %s", PCB_toString(nextProcess)); fprintf(file, "Ready Queue: %s", Queue_toString(cpu->readyQueue, 0)); } // 5. Return to the scheduler // returns prevalent stuff to scheduler, but not for this project return; }
/** * @brief Peeks into receive buffer to see if given char was received * @param b byte to check the queue for * @retval returns position in the buffer or 0 when not present */ uint8_t usart_peekc(uint8_t b) { return Queue_peek(&rxbuf, b); }