/** * Set the process priority from LOWEST to HIGHEST, check if returns correct */ void test_proc_p1_4() { int i = 0; int ret; int proc = 3; while (1) { //printf("Process 4\r\n"); ret = get_process_priority(g_test_procs[proc].pid); if (ret != LOW) { test_results[g_test_procs[proc].pid] = 0; } ret = set_process_priority(g_test_procs[proc].pid, HIGH); if (ret != 0) { test_results[g_test_procs[proc].pid] = 0; } ret = get_process_priority(g_test_procs[proc].pid); if (ret != HIGH) { test_results[g_test_procs[proc].pid] = 0; } ret = set_process_priority(g_test_procs[proc].pid, LOW); if (ret != 0) { test_results[g_test_procs[proc].pid] = 0; } if (i == 0) { if (test_results[proc] == 1) { printf("G005_test: test 4 OK\r\n"); } else { printf("G005_test: test 4 FAIL\r\n"); } } i = 1; ret = release_processor(); } }
/* third party dummy test process 1 */ void test1() { int i; printf_u_0("rtx_test: test1\r\n", 1); set_process_priority(1, 1); printf_u_1("Getting priority for PID 1: %i\n\r", get_process_priority(1)); set_process_priority(2, 1); printf_u_1("Getting priority for PID 2: %i\n\r", get_process_priority(2)); set_process_priority(1, 3); printf_u_1("Getting priority for PID 1: %i\n\r", get_process_priority(1)); set_process_priority(2, 3); printf_u_1("Getting priority for PID 2: %i\n\r", get_process_priority(2)); i = 0; while (1) { g_test_fixture.release_processor(); } }
void proc2(void) { if (get_process_priority(1) != LOW || get_process_priority(2) != MEDIUM || get_process_priority(3) != LOWEST || get_process_priority(4) != LOWEST || get_process_priority(5) != LOWEST || get_process_priority(6) != HIGH) { prev_success = 0; } prev_pid = 2; // TC 3b: allocate all memory blocks, free one, return release_memory_block(mem[--index]); //jumps back to proc_6 // TC 3c: with 2 procs at highest priority, block both procs, then release memory in another proc to return to proc_6 prev_pid = 2; release_memory_block(mem[--index]); //jumps to proc_3 // TC 3d: Block everything and preempt to null process after starvation if (prev_pid != 1) { prev_success = 0; } // 1: MEDIUM, blocked // 2: LOW, will be blocked // 3: HIGH, blocked // 4, 5: LOWEST // 6: HIGH, blocked prev_pid = 2; mem[index++] = request_memory_block(); }
void proc5(void) { // TESTING PRIORITY LEVEL SETTER - SETTING PRIORITY OF ANOTHER PROCESS - FAILS while (1) { int result; result = 1; set_process_priority(4,2); if (get_process_priority(4) == 2) result = 0; results[5] = result; release_processor(); } }
void proc4(void) { // TESTING PRIORITY LEVEL SETTER - CORRECT USAGE while (1) { int result; result = 1; set_process_priority(4,2); if (get_process_priority(4) != 2) result = 0; set_process_priority(4,3); results[4] = result; release_processor(); } }
void proc3(void) { // TESTING PRIORITY LEVEL GETTER int i = 1; while (i) { int result; result = 1; if (get_process_priority(3) != 3) result = 0; results[3] = result; if (i == 6) release_memory_block(lastMemBlock); i++; release_processor(); } }