コード例 #1
0
ファイル: test_dispatcher_7.c プロジェクト: AbhijitParate/TOS
void test_dispatcher_7_process_e(PROCESS self, PARAM param)
{
    kprintf("%s\n", self->name);
    if (check_sum != 1)
       test_failed(23);

    check_sum += 2;
    remove_ready_queue(self);
    check_num_proc_on_ready_queue(3);
    if (test_result != 0)
       test_failed(test_result);

    resign();
    test_failed(26);
}
コード例 #2
0
ファイル: test_ipc_2.c プロジェクト: weighan/tos
/*
 * This test creates a sender and a receiver process. The sender process
 * has the higher priority and will be scheduled first.
 * The execution sequence is as follow:
 * 1. The sender executes a send(). Since the receiver is not RECEIVE_BLOCKED,
 *    the sender will be SEND_BLOCKED.
 * 2. Execution resumes with the receiver. The receiver executes a receive(),
 *    which will return immediately, and change the sender to state
 *    REPLY_BLOCKED.
 * 3. The receivers does a reply(), and put the sender back on the ready queue.
 *    The resign() in the reply() will therefore transfer the control back to
 *    the sender.
 * 4. The sender executes a message(). Since the receiver is not
 *    RECEIVE_BLOCKED, the sender will be MESSAGE_BLOCKED.
 * 5. Execution resumes with the receiver. The receiver executes a receive(),
 *    which will return immediately, and change the sender to STATE_READY.
 * 6. The receiver does a resign() and pass the execution back to the sender.
 * This test send() and message() in the case that the receiver is not
 * ready to receive. It also test receive() in the case that there are messages
 * pending.
 */
void test_ipc_2 ()
{
    PORT new_port;

    test_reset();
    new_port = create_process (test_ipc_2_receiver_process, 5, 0, "Receiver");
    create_process (test_ipc_2_sender_process, 6, (PARAM) new_port, "Sender");

    check_num_proc_on_ready_queue(3);
    check_process("Sender", STATE_READY, TRUE);
    check_process("Receiver", STATE_READY, TRUE);
    if (test_result != 0)
       test_failed(test_result);

    resign();
}
コード例 #3
0
ファイル: test_dispatcher_4.c プロジェクト: AbhijitParate/TOS
void test_dispatcher_4_process_c(PROCESS self, PARAM param)
{
    kprintf("\nProcess: %s\n\n", self->name);
    print_all_processes(kernel_window);
    kprintf("\n");

    if (check_sum != 0)
       test_failed(22);

    check_sum += 2;
    remove_ready_queue(active_proc);
    check_num_proc_on_ready_queue(2);
    if (test_result != 0)
       test_failed(test_result);

    resign();

    test_failed(26); 
}
コード例 #4
0
/*
 * We don't explicitly create a new process, but because of init_process()
 * and init_dispatcher(), the main thread should be initialized as a process
 * and be added to the ready queue.  
 * This also test print_all_processes() 
 */
void test_create_process_1() 
{
    test_reset();
    print_all_processes(kernel_window);

    //check if the boot process is initialized correctly.
    check_create_process(boot_name, 1, NULL, 0);
    if (test_result != 0) 
       test_failed(test_result);

    check_num_of_pcb_entries(1);
    if (test_result != 0)
       test_failed(test_result);

    check_process(boot_name, STATE_READY, TRUE);
    if (test_result != 0)
       test_failed(test_result);

    check_num_proc_on_ready_queue(1);
    if (test_result != 0)
       test_failed(test_result);
}
コード例 #5
0
ファイル: test_dispatcher_7.c プロジェクト: AbhijitParate/TOS
/*
 * This test creates three processes with the same priority.
 * The execution sequence is as following:
 * 1. After the boot process resign(),  process F (test_process_f)is executed.
 * 2. Process F resign, process E (test_process_e) is then executed. 
 * 3. Process E remove itself from the ready queue and then resign, process D
 *    (test_process_d) is then executed.
 * 4. Process D resign(), process F is then executed.
 * 5. Process F remove itself from ready queue and then resign. Process D is
 *    the next to be executed since Process E is off ready queue.    
 * 6. Process D resign, the next to be executed is still process D since both
 *    process F and E are off ready queue. 
 * 
 * The execution sequence should be: boot -> F -> E -> D -> F -> D -> D
*/
void test_dispatcher_7()
{
    test_reset();
    create_process(test_dispatcher_7_process_f, 5, 0, "Test process F");
    kprintf("Created process F\n");
    create_process(test_dispatcher_7_process_e, 5, 0, "Test process E");
    kprintf("Created process E\n");
    create_process(test_dispatcher_7_process_d, 5, 0, "Test process D");
    kprintf("Created process D\n");
    kprintf("\n");

    check_num_proc_on_ready_queue(4);
    if (test_result != 0)
       test_failed(test_result);

    check_sum = 0;
    resign();
    if(check_sum == 0)
       test_failed(21);

    if (check_sum != 63)
       test_failed(25);
}