/* Inicio de rutina para inicializar el entorno de accion */ void main(void){ struct get_process_status_type g_p_s; RETURN_CODE_TYPE retCode; PROCESS_ID_TYPE procMainIdMT; PROCESS_ID_TYPE procMainId1; char sal_code[MAX_CAD]; PROCESS_STATUS_TYPE status; CREATE_PROCESS (&processTable[0], /* process attribute */ &procMainIdMT, /* process Id */ &retCode); CHECK_CODE(": CREATE_PROCESS Process Master Test", retCode, sal_code); printf("%s\n", sal_code); CREATE_PROCESS (&processTable[1], /* process attribute */ &procMainId1, /* process Id */ &retCode); CHECK_CODE(": CREATE_PROCESS Process 1", retCode, sal_code); printf("%s\n", sal_code); /* To get the init values of Process 1*/ status = initStatus(); /* check process 1 status */ g_p_s = checkget_process_status(status, procMainId1, NO_ERROR); show_resultget_p(g_p_s); SET_PARTITION_MODE(NORMAL, &retCode); CHECK_CODE(": SET_PARTITION_MODE", retCode, sal_code); printf("%s\n", sal_code); }
void test2g(void) { static long sleep_time = 1000; printf("This is Release %s: Test 2g\n", CURRENT_REL); CREATE_PROCESS("test2g_a", test2f, PRIORITY2G, &Z502_REG1, &Z502_REG9); CREATE_PROCESS("test2g_b", test2f, PRIORITY2G, &Z502_REG2, &Z502_REG9); CREATE_PROCESS("test2g_c", test2f, PRIORITY2G, &Z502_REG3, &Z502_REG9); CREATE_PROCESS("test2g_d", test2f, PRIORITY2G, &Z502_REG4, &Z502_REG9); CREATE_PROCESS("test2g_e", test2f, PRIORITY2G, &Z502_REG5, &Z502_REG9); SuccessExpected(Z502_REG9, "CREATE_PROCESS"); // In these next three cases, we will loop until the target // process ( test2g_e ) has terminated. We know it // terminated because for a while we get success on the call // GET_PROCESS_ID, and then we get failure when the process // no longer exists. Z502_REG9 = ERR_SUCCESS; while (Z502_REG9 == ERR_SUCCESS) { SLEEP(sleep_time); GET_PROCESS_ID("test2g_e", &Z502_REG6, &Z502_REG9); } TERMINATE_PROCESS(-2, &Z502_REG9); // Terminate all } // End test2g
/* Entry point */ void main(void){ PROCESS_ID_TYPE procMainIdMT; PROCESS_ID_TYPE procMainId1; PROCESS_ID_TYPE procMainId2; RETURN_CODE_TYPE retCode; char sal_code[MAX_CAD]; CREATE_PROCESS (&processTable[0], /* process attribute */ &procMainIdMT, /* process Id */ &retCode); CHECK_CODE(": CREATE_PROCESS Master Test", retCode, sal_code); printf("%s\n", sal_code); CREATE_PROCESS (&processTable[1], /* process attribute */ &procMainId1, /* process Id */ &retCode); CHECK_CODE(": CREATE_PROCESS Process 1", retCode, sal_code); printf("%s\n", sal_code); CREATE_PROCESS (&processTable[2], /* process attribute */ &procMainId2, /* process Id */ &retCode); CHECK_CODE(": CREATE_PROCESS Process 2", retCode, sal_code); printf("%s\n", sal_code); START(procMainIdMT, &retCode); CHECK_CODE(": START Master Test", retCode, sal_code); printf("%s\n", sal_code); /* To set the partition in a Normal State */ SET_PARTITION_MODE(NORMAL, &retCode); CHECK_CODE(": SET_PARTITION_MODE", retCode, sal_code); printf("%s\n", sal_code); }
/* -----------------------------------------------------------------------------------*/ void main(void){ struct create_process_error_type c_p_e; RETURN_CODE_TYPE retCode; PROCESS_ID_TYPE procMainIdMT; PROCESS_ID_TYPE procMainId1; char sal_code[MAX_CAD]; /* Create Process Master Test */ CREATE_PROCESS (&processTable[0], /* process attribute */ &procMainIdMT, /* process Id */ &retCode); CHECK_CODE(": CREATE_PROCESS Process Master Test", retCode, sal_code); printf("%s\n", sal_code); /* Create Process 1 */ CREATE_PROCESS (&processTable[1], /* process attribute */ &procMainId1, /* process Id */ &retCode); c_p_e = checkcreate_process(processTable[1], procMainId1, retCode, NO_ERROR); show_result(c_p_e); /* Create Process 1 again */ CREATE_PROCESS (&processTable[1], /* process attribute */ &procMainId1, /* process Id */ &retCode); c_p_e = checkcreate_process(processTable[1], procMainId1, retCode, NO_ACTION); show_result(c_p_e); }
void test1d(void) { static long sleep_time = 1000; printf("This is Release %s: Test 1d\n", CURRENT_REL); CREATE_PROCESS("test1d_1", test1x, PRIORITY1, &Z502_REG1, &Z502_REG9); SuccessExpected(Z502_REG9, "CREATE_PROCESS"); CREATE_PROCESS("test1d_2", test1x, PRIORITY2, &Z502_REG2, &Z502_REG9); CREATE_PROCESS("test1d_3", test1x, PRIORITY3, &Z502_REG3, &Z502_REG9); CREATE_PROCESS("test1d_4", test1x, PRIORITY4, &Z502_REG4, &Z502_REG9); CREATE_PROCESS("test1d_5", test1x, PRIORITY5, &Z502_REG5, &Z502_REG9); // Now we sleep, see if one of the five processes has terminated, and // continue the cycle until one of them is gone. This allows the test1x // processes to exhibit scheduling. // We know that the process terminated when we do a GET_PROCESS_ID and // receive an error on the system call. Z502_REG9 = ERR_SUCCESS; while (Z502_REG9 == ERR_SUCCESS) { SLEEP(sleep_time); GET_PROCESS_ID("test1d_4", &Z502_REG6, &Z502_REG9); } TERMINATE_PROCESS(-2, &Z502_REG9); } // End test1d
void test1b(void) { static char process_name[16]; // Try to create a process with an illegal priority. printf("This is Release %s: Test 1b\n", CURRENT_REL); CREATE_PROCESS("test1b_a", test1x, ILLEGAL_PRIORITY, &Z502_REG1, &Z502_REG9); ErrorExpected(Z502_REG9, "CREATE_PROCESS"); // Create two processes with same name - 1st succeeds, 2nd fails // Then terminate the process that has been created CREATE_PROCESS("two_the_same", test1x, LEGAL_PRIORITY, &Z502_REG2, &Z502_REG9); SuccessExpected(Z502_REG9, "CREATE_PROCESS"); CREATE_PROCESS("two_the_same", test1x, LEGAL_PRIORITY, &Z502_REG1, &Z502_REG9); ErrorExpected(Z502_REG9, "CREATE_PROCESS"); TERMINATE_PROCESS(Z502_REG2, &Z502_REG9); SuccessExpected(Z502_REG9, "TERMINATE_PROCESS"); // Loop until an error is found on the create_process. // Since the call itself is legal, we must get an error // because we exceed some limit. Z502_REG9 = ERR_SUCCESS; while (Z502_REG9 == ERR_SUCCESS) { Z502_REG3++; /* Generate next unique program name*/ sprintf(process_name, "Test1b_%ld", Z502_REG3); printf("Creating process \"%s\"\n", process_name); CREATE_PROCESS(process_name, test1x, LEGAL_PRIORITY, &Z502_REG1, &Z502_REG9); } // When we get here, we've created all the processes we can. // So the OS should have given us an error ErrorExpected(Z502_REG9, "CREATE_PROCESS"); printf("%ld processes were created in all.\n", Z502_REG3); // Now test the call GET_PROCESS_ID for ourselves GET_PROCESS_ID("", &Z502_REG2, &Z502_REG9); // Legal SuccessExpected(Z502_REG9, "GET_PROCESS_ID"); printf("The PID of this process is %ld\n", Z502_REG2); // Try GET_PROCESS_ID on another existing process strcpy(process_name, "Test1b_1"); GET_PROCESS_ID(process_name, &Z502_REG1, &Z502_REG9); /* Legal */ SuccessExpected(Z502_REG9, "GET_PROCESS_ID"); printf("The PID of target process is %ld\n", Z502_REG1); // Try GET_PROCESS_ID on a non-existing process GET_PROCESS_ID("bogus_name", &Z502_REG1, &Z502_REG9); // Illegal ErrorExpected(Z502_REG9, "GET_PROCESS_ID"); GET_TIME_OF_DAY(&Z502_REG4); printf("Test1b, PID %ld, Ends at Time %ld\n", Z502_REG2, Z502_REG4); TERMINATE_PROCESS(-2, &Z502_REG9) } // End of test1b
//**************************************************************************** // Preemptive-based Dispatching Test // Please type “cs502 test1l?and see my preemptive algorithm implemented in // the scheduler module. Notice that processes 3 and 4 with high priorities // get much more chances running than process 5, 6 and 7 who have low // priorities. //**************************************************************************** void mytest(void) { CREATE_PROCESS("mytest_a", mytestx, PRIORITY_1, &Z502_REG3, &Z502_REG9); CREATE_PROCESS("mytest_b", mytestx, PRIORITY_2, &Z502_REG4, &Z502_REG9); CREATE_PROCESS("mytest_c", mytestx, PRIORITY_3, &Z502_REG5, &Z502_REG9); CREATE_PROCESS("mytest_d", mytestx, PRIORITY_4, &Z502_REG6, &Z502_REG9); CREATE_PROCESS("mytest_e", mytestx, PRIORITY_5, &Z502_REG7, &Z502_REG9); SLEEP(2000); TERMINATE_PROCESS(-2, &Z502_REG9); }
int main () { PROCESS_ATTRIBUTE_TYPE tattr; RETURN_CODE_TYPE ret; CREATE_BLACKBOARD ("TrainPpu_trainTraction_tractionIn_globalVariable", sizeof (cbtc_refined_model__TractionData_freshness_t_impl), &(TrainPpu_trainTraction_tractionIn_globalVariable), &(ret)); CREATE_BLACKBOARD ("VobcTrainPositionEstimation_vobcTrainPositionEstimation_additionalTrainPositionOffset_globalVariable", sizeof (TrainPositionOffset), &(VobcTrainPositionEstimation_vobcTrainPositionEstimation_additionalTrainPositionOffset_globalVariable), &(ret)); CREATE_BLACKBOARD ("VobcTrainPositionEstimation_vobcTrainPositionEstimation_wheelAngleIn_globalVariable", sizeof (cbtc_refined_model__OdometerData_freshness_t_impl), &(VobcTrainPositionEstimation_vobcTrainPositionEstimation_wheelAngleIn_globalVariable), &(ret)); CREATE_BLACKBOARD ("TrainSpeedAccelCompute_trainSpeedAccelCompute_trainPositionIn_globalVariable", sizeof (cbtc_refined_model__VobcData_freshness_t_impl), &(TrainSpeedAccelCompute_trainSpeedAccelCompute_trainPositionIn_globalVariable), &(ret)); CREATE_SAMPLING_PORT ("train_inst_TrainSpeedAccelCompute_inst_eoaIn", sizeof( cbtc_refined_model__EndOfAuthority_freshness_t_impl ), DESTINATION, 10, &(train_inst_TrainSpeedAccelCompute_inst_eoaInglobalVariable), &(ret)); CREATE_SAMPLING_PORT ("train_inst_TrainSpeedAccelCompute_inst_trainPositionForMauOut", sizeof( cbtc_refined_model__VobcData_freshness_t_impl ), SOURCE, 10, &(train_inst_TrainSpeedAccelCompute_inst_trainPositionForMauOut_globalVariable), &(ret)); CREATE_SAMPLING_PORT ("train_inst_trainPpu_inst_trainDataOut", sizeof( TrainData ), SOURCE, 10, &(train_inst_trainPpu_inst_trainDataOut_globalVariable), &(ret)); CREATE_SAMPLING_PORT ("train_inst_trainPpu_inst_trainDataIn", sizeof( cbtc_refined_model__TrainData_freshness_t_impl ), DESTINATION, 10, &(train_inst_trainPpu_inst_trainDataInglobalVariable), &(ret)); tattr.ENTRY_POINT = cbtc_refined_model__train_inst_TrainPpu_odometerAcquisition_impl_Job; tattr.PERIOD = 300; tattr.DEADLINE = 300; tattr.BASE_PRIORITY = 1; strcpy(tattr.NAME, "TrainPpu_odometerAcquisition"); CREATE_PROCESS (&(tattr), &(arinc_threads[1]), &(ret)); START (arinc_threads[1], &(ret)); tattr.ENTRY_POINT = cbtc_refined_model__train_inst_TrainPpu_trainTraction_impl_Job; tattr.PERIOD = 300; tattr.DEADLINE = 300; tattr.BASE_PRIORITY = 1; strcpy(tattr.NAME, "TrainPpu_trainTraction"); CREATE_PROCESS (&(tattr), &(arinc_threads[2]), &(ret)); START (arinc_threads[2], &(ret)); tattr.ENTRY_POINT = cbtc_refined_model__train_inst_VobcTrainPositionEstimation_vobcTrainPositionEstimation_impl_Job; tattr.PERIOD = 300; tattr.DEADLINE = 300; tattr.BASE_PRIORITY = 2; strcpy(tattr.NAME, "VobcTrainPositionEstimation_vobcTrainPositionEstimation"); CREATE_PROCESS (&(tattr), &(arinc_threads[3]), &(ret)); START (arinc_threads[3], &(ret)); tattr.ENTRY_POINT = cbtc_refined_model__train_inst_TrainSpeedAccelCompute_trainSpeedAccelCompute_impl_Job; tattr.PERIOD = 300; tattr.DEADLINE = 300; tattr.BASE_PRIORITY = 2; strcpy(tattr.NAME, "TrainSpeedAccelCompute_trainSpeedAccelCompute"); CREATE_PROCESS (&(tattr), &(arinc_threads[4]), &(ret)); START (arinc_threads[4], &(ret)); SET_PARTITION_MODE (NORMAL, &(ret)); return (0); }
void test1f(void) { static long sleep_time = 300; int iterations; // Get OUR PID Z502_REG1 = 0; // Initialize GET_PROCESS_ID("", &Z502_REG2, &Z502_REG9); // Make legal targets printf("Release %s:Test 1f: Pid %ld\n", CURRENT_REL, Z502_REG2); CREATE_PROCESS("test1f_a", test1x, PRIORITY_1F1, &Z502_REG3, &Z502_REG9); CREATE_PROCESS("test1f_b", test1x, PRIORITY_1F2, &Z502_REG4, &Z502_REG9); CREATE_PROCESS("test1f_c", test1x, PRIORITY_1F3, &Z502_REG5, &Z502_REG9); CREATE_PROCESS("test1f_d", test1x, PRIORITY_1F4, &Z502_REG6, &Z502_REG9); CREATE_PROCESS("test1f_e", test1x, PRIORITY_1F5, &Z502_REG7, &Z502_REG9); // Let the 5 processes go for a while SLEEP(sleep_time); // Do a set of suspends/resumes four times for (iterations = 0; iterations < 4; iterations++) { // Suspend 3 of the pids and see what happens - we should see // scheduling behavior where the processes are yanked out of the // ready and the waiting states, and placed into the suspended state. SUSPEND_PROCESS(Z502_REG3, &Z502_REG9); SUSPEND_PROCESS(Z502_REG5, &Z502_REG9); SUSPEND_PROCESS(Z502_REG7, &Z502_REG9); // Sleep so we can watch the scheduling action SLEEP(sleep_time); RESUME_PROCESS(Z502_REG3, &Z502_REG9); RESUME_PROCESS(Z502_REG5, &Z502_REG9); RESUME_PROCESS(Z502_REG7, &Z502_REG9); } // Wait for children to finish, then quit SLEEP((INT32) 10000); TERMINATE_PROCESS(-2, &Z502_REG9); } // End of test1f
void test1h(void) { long ourself; GET_PROCESS_ID("", &Z502_REG2, &Z502_REG9); // Make our priority high printf("Release %s:Test 1h: Pid %ld\n", CURRENT_REL, Z502_REG2); ourself = -1; CHANGE_PRIORITY(ourself, MOST_FAVORABLE_PRIORITY, &Z502_REG9); // Make legal targets CREATE_PROCESS("test1h_a", test1x, NORMAL_PRIORITY, &Z502_REG3, &Z502_REG9); CREATE_PROCESS("test1h_b", test1x, NORMAL_PRIORITY, &Z502_REG4, &Z502_REG9); CREATE_PROCESS("test1h_c", test1x, NORMAL_PRIORITY, &Z502_REG5, &Z502_REG9); // Sleep awhile to watch the scheduling SLEEP(200); // Now change the priority - it should be possible to see // that the priorities have been changed for processes that // are ready and for processes that are sleeping. CHANGE_PRIORITY(Z502_REG3, FAVORABLE_PRIORITY, &Z502_REG9); CHANGE_PRIORITY(Z502_REG5, LEAST_FAVORABLE_PRIORITY, &Z502_REG9); // Sleep awhile to watch the scheduling SLEEP(200); // Now change the priority - it should be possible to see // that the priorities have been changed for processes that // are ready and for processes that are sleeping. CHANGE_PRIORITY(Z502_REG3, LEAST_FAVORABLE_PRIORITY, &Z502_REG9); CHANGE_PRIORITY(Z502_REG4, FAVORABLE_PRIORITY, &Z502_REG9); // Sleep awhile to watch the scheduling SLEEP(600); // Terminate everyone TERMINATE_PROCESS(-2, &Z502_REG9); } // End of test1h
int main () { PROCESS_ATTRIBUTE_TYPE tattr; RETURN_CODE_TYPE ret; CREATE_SAMPLING_PORT ("S1_inst_Mon_mode_C2", sizeof( ROLE ), SOURCE, 10, &(S1_inst_Mon_mode_C2_globalVariable), &(ret)); CREATE_SAMPLING_PORT ("S1_inst_C1_PingOut", sizeof( PingPongMessage ), SOURCE, 10, &(S1_inst_C1_PingOut_globalVariable), &(ret)); CREATE_SAMPLING_PORT ("S1_inst_C1_PongOut", sizeof( PingPongMessage ), SOURCE, 10, &(S1_inst_C1_PongOut_globalVariable), &(ret)); CREATE_SAMPLING_PORT ("S1_inst_C1_PingIn", sizeof( PingPongMessage ), DESTINATION, 10000, &(S1_inst_C1_PingInglobalVariable), &(ret)); CREATE_SAMPLING_PORT ("S1_inst_C1_PongIn", sizeof( PingPongMessage ), DESTINATION, 10000, &(S1_inst_C1_PongInglobalVariable), &(ret)); CREATE_SAMPLING_PORT ("S1_inst_Mon_error_C2", sizeof( PingPong__Exception ), DESTINATION, 10000, &(S1_inst_Mon_error_C2globalVariable), &(ret)); tattr.ENTRY_POINT = PingPong_refined_model__S1_inst_a1_inst_impl_Job; tattr.PERIOD = 2000; tattr.DEADLINE = 2000; tattr.BASE_PRIORITY = 1; strcpy(tattr.NAME, "a1_inst"); CREATE_PROCESS (&(tattr), &(arinc_threads[1]), &(ret)); START (arinc_threads[1], &(ret)); SET_PARTITION_MODE (NORMAL, &(ret)); return (0); }
void test1g(void) { GET_PROCESS_ID("", &Z502_REG2, &Z502_REG9); printf("Release %s:Test 1g: Pid %ld\n", CURRENT_REL, Z502_REG2); // Make a legal target CREATE_PROCESS("test1g_a", test1x, LEGAL_PRIORITY_1G, &Z502_REG1, &Z502_REG9); SuccessExpected(Z502_REG9, "CREATE_PROCESS"); // Target Illegal PID CHANGE_PRIORITY((INT32) 9999, LEGAL_PRIORITY_1G, &Z502_REG9); ErrorExpected(Z502_REG9, "CHANGE_PRIORITY"); // Use illegal priority CHANGE_PRIORITY(Z502_REG1, ILLEGAL_PRIORITY_1G, &Z502_REG9); ErrorExpected(Z502_REG9, "CHANGE_PRIORITY"); // Use legal priority on legal process CHANGE_PRIORITY(Z502_REG1, LEGAL_PRIORITY_1G, &Z502_REG9); SuccessExpected(Z502_REG9, "CHANGE_PRIORITY"); // Terminate all existing processes TERMINATE_PROCESS(-2, &Z502_REG9); } // End of test1g
int main () { PROCESS_ATTRIBUTE_TYPE tattr; RETURN_CODE_TYPE ret; CREATE_BLACKBOARD ("IPingOrPong_Cping_ping_delayed_PongIn_globalVariable", sizeof (PingPongMessage), &(IPingOrPong_Cping_ping_delayed_PongIn_globalVariable), &(ret)); CREATE_SAMPLING_PORT ("S2_inst_C2_mode", sizeof( ROLE ), DESTINATION, 10, &(S2_inst_C2_modeglobalVariable), &(ret)); CREATE_SAMPLING_PORT ("S2_inst_C2_PingIn", sizeof( PingPong_refined_model__PingPongMessage_freshness_t_impl ), DESTINATION, 10, &(S2_inst_C2_PingInglobalVariable), &(ret)); CREATE_SAMPLING_PORT ("S2_inst_C2_PongIn", sizeof( PingPongMessage ), DESTINATION, 10, &(S2_inst_C2_PongInglobalVariable), &(ret)); CREATE_SAMPLING_PORT ("S2_inst_C2_PingOut", sizeof( PingPong_refined_model__PingPongMessage_freshness_t_impl ), SOURCE, 10, &(S2_inst_C2_PingOut_globalVariable), &(ret)); CREATE_SAMPLING_PORT ("S2_inst_C2_PongOut", sizeof( PingPongMessage ), SOURCE, 10, &(S2_inst_C2_PongOut_globalVariable), &(ret)); CREATE_SAMPLING_PORT ("S2_inst_C2_badSequenceNumber", sizeof( Exception ), SOURCE, 10, &(S2_inst_C2_badSequenceNumber_globalVariable), &(ret)); tattr.ENTRY_POINT = PingPong_refined_model__S2_inst_IPingOrPong_Cping_ping_impl_Job; tattr.PERIOD = 40; tattr.DEADLINE = 40; tattr.BASE_PRIORITY = 3; strcpy(tattr.NAME, "IPingOrPong_Cping_ping"); CREATE_PROCESS (&(tattr), &(arinc_threads[1]), &(ret)); START (arinc_threads[1], &(ret)); tattr.ENTRY_POINT = PingPong_refined_model__S2_inst_IPingOrPong_Cping_delayed_PongIn_impl_Job; tattr.PERIOD = 40; tattr.DEADLINE = 40; tattr.BASE_PRIORITY = 3; strcpy(tattr.NAME, "IPingOrPong_Cping_delayed_PongIn"); CREATE_PROCESS (&(tattr), &(arinc_threads[2]), &(ret)); START (arinc_threads[2], &(ret)); tattr.ENTRY_POINT = PingPong_refined_model__S2_inst_IPingOrPong_Cpong_pong_impl_Job; tattr.PERIOD = 40; tattr.DEADLINE = 40; tattr.BASE_PRIORITY = 3; strcpy(tattr.NAME, "IPingOrPong_Cpong_pong"); CREATE_PROCESS (&(tattr), &(arinc_threads[3]), &(ret)); START (arinc_threads[3], &(ret)); SET_PARTITION_MODE (NORMAL, &(ret)); return (0); }
void test2d(void) { static INT32 trash; GET_PROCESS_ID("", &Z502_REG4, &Z502_REG5); printf("\n\nRelease %s:Test 2d: Pid %ld\n", CURRENT_REL, Z502_REG4); CHANGE_PRIORITY(-1, MOST_FAVORABLE_PRIORITY, &Z502_REG9); CREATE_PROCESS("first", test2c, 5, &trash, &Z502_REG5); CREATE_PROCESS("second", test2c, 5, &trash, &Z502_REG5); CREATE_PROCESS("third", test2c, 7, &trash, &Z502_REG5); CREATE_PROCESS("fourth", test2c, 7, &trash, &Z502_REG5); CREATE_PROCESS("fifth", test2c, 7, &trash, &Z502_REG5); SLEEP(50000); TERMINATE_PROCESS(-2, &Z502_REG5); } // End of test2d
void test1e(void) { GET_PROCESS_ID("", &Z502_REG2, &Z502_REG9); printf("Release %s:Test 1e: Pid %ld\n", CURRENT_REL, Z502_REG2); // Make a legal target process CREATE_PROCESS("test1e_a", test1x, LEGAL_PRIORITY_1E, &Z502_REG1, &Z502_REG9); SuccessExpected(Z502_REG9, "CREATE_PROCESS"); // Try to Suspend an Illegal PID SUSPEND_PROCESS((INT32) 9999, &Z502_REG9); ErrorExpected(Z502_REG9, "SUSPEND_PROCESS"); // Try to Resume an Illegal PID RESUME_PROCESS((INT32) 9999, &Z502_REG9); ErrorExpected(Z502_REG9, "RESUME_PROCESS"); // Suspend alegal PID SUSPEND_PROCESS(Z502_REG1, &Z502_REG9); SuccessExpected(Z502_REG9, "SUSPEND_PROCESS"); // Suspend already suspended PID SUSPEND_PROCESS(Z502_REG1, &Z502_REG9); ErrorExpected(Z502_REG9, "SUSPEND_PROCESS"); // Do a legal resume of the process we have suspended RESUME_PROCESS(Z502_REG1, &Z502_REG9); SuccessExpected(Z502_REG9, "RESUME_PROCESS"); // Resume an already resumed process RESUME_PROCESS(Z502_REG1, &Z502_REG9); ErrorExpected(Z502_REG9, "RESUME_PROCESS"); // Try to resume ourselves RESUME_PROCESS(Z502_REG2, &Z502_REG9); ErrorExpected(Z502_REG9, "RESUME_PROCESS"); // It may or may not be legal to suspend ourselves; // architectural decision. It can be a useful technique // as a way to pass off control to another process. SUSPEND_PROCESS(-1, &Z502_REG9); /* If we returned "SUCCESS" here, then there is an inconsistency; * success implies that the process was suspended. But if we * get here, then we obviously weren't suspended. Therefore * this must be an error. */ ErrorExpected(Z502_REG9, "SUSPEND_PROCESS"); GET_TIME_OF_DAY(&Z502_REG4); printf("Test1e, PID %ld, Ends at Time %ld\n", Z502_REG2, Z502_REG4); TERMINATE_PROCESS(-2, &Z502_REG9); } // End of test1e
int main () { PROCESS_ATTRIBUTE_TYPE tattr; RETURN_CODE_TYPE ret; printf(" part1 - Main thread\n"); CREATE_EVENT (pok_arinc653_events_names[0], &(pok_arinc653_events_ids[0]), &(ret)); printf(" Event %s created! EVENT ID: %u, ret: %d \n", pok_arinc653_events_names[0], pok_arinc653_events_ids[0], ret); tattr.PERIOD = 400; tattr.BASE_PRIORITY = 10; tattr.ENTRY_POINT = thr1_1_job; CREATE_PROCESS (&(tattr), &(arinc_threads[1]), &(ret)); tattr.PERIOD = APERIODIC_PROCESS; tattr.BASE_PRIORITY = 9; tattr.ENTRY_POINT = thr1_1bis_job; CREATE_PROCESS (&(tattr), &(arinc_threads[2]), &(ret)); tattr.PERIOD = 400; tattr.BASE_PRIORITY = 8; tattr.ENTRY_POINT = thr1_3_job; CREATE_PROCESS (&(tattr), &(arinc_threads[3]), &(ret)); tattr.PERIOD = APERIODIC_PROCESS; tattr.BASE_PRIORITY = 7; tattr.ENTRY_POINT = thr1_3bis_job; CREATE_PROCESS (&(tattr), &(arinc_threads[4]), &(ret)); START (arinc_threads[1],&(ret)); START (arinc_threads[2],&(ret)); START (arinc_threads[3],&(ret)); START (arinc_threads[4],&(ret)); SET_PARTITION_MODE (NORMAL, &(ret)); return 0; }
int main () { PROCESS_ATTRIBUTE_TYPE tattr; RETURN_CODE_TYPE ret; printf(" part3 - Main thread\n"); tattr.PERIOD = 400; tattr.BASE_PRIORITY = 8; tattr.ENTRY_POINT = thr3_1_job; CREATE_PROCESS (&(tattr), &(arinc_threads[1]), &(ret)); tattr.PERIOD = 400; tattr.BASE_PRIORITY = 8; tattr.ENTRY_POINT = thr3_2_job; CREATE_PROCESS (&(tattr), &(arinc_threads[2]), &(ret)); START (arinc_threads[2],&(ret)); SET_PARTITION_MODE (NORMAL, &(ret)); return 0; }
int main () { PROCESS_ATTRIBUTE_TYPE tattr; RETURN_CODE_TYPE ret; tattr.ENTRY_POINT = test_buffer_delayed_refined_model__the_proc_the_sender_impl_Job; tattr.PERIOD = 2000; tattr.DEADLINE = 2000; tattr.TIME_CAPACITY = 1; tattr.BASE_PRIORITY = 5; strcpy(tattr.NAME, "the_sender"); CREATE_PROCESS (&(tattr), &(arinc_threads[1]), &(ret)); START (arinc_threads[1], &(ret)); tattr.ENTRY_POINT = test_buffer_delayed_refined_model__the_proc_the_receiver_impl_Job; tattr.PERIOD = 1000; tattr.DEADLINE = 1000; tattr.TIME_CAPACITY = 1; tattr.BASE_PRIORITY = 10; strcpy(tattr.NAME, "the_receiver"); CREATE_PROCESS (&(tattr), &(arinc_threads[2]), &(ret)); START (arinc_threads[2], &(ret)); SET_PARTITION_MODE (NORMAL, &(ret)); return (0); }
int main () { PROCESS_ATTRIBUTE_TYPE tattr; RETURN_CODE_TYPE ret; CREATE_QUEUING_PORT ("the_proc2_p_in", sizeof( common_pkg__Integer ), 10, DESTINATION, FIFO, &(the_proc2_p_inglobalVariable), &(ret)); tattr.ENTRY_POINT = test_queuing_refined_model__the_proc2_the_receiver_impl_Job; tattr.PERIOD = 1000; tattr.DEADLINE = 1000; tattr.TIME_CAPACITY = 1; tattr.BASE_PRIORITY = 10; strcpy(tattr.NAME, "the_receiver"); CREATE_PROCESS (&(tattr), &(arinc_threads[1]), &(ret)); START (arinc_threads[1], &(ret)); SET_PARTITION_MODE (NORMAL, &(ret)); return (0); }
int main () { PROCESS_ATTRIBUTE_TYPE tattr; RETURN_CODE_TYPE ret; tattr.ENTRY_POINT = thr2_job; tattr.DEADLINE = 600; tattr.PERIOD = 1000; tattr.STACK_SIZE = 4000; tattr.TIME_CAPACITY = 1; CREATE_PROCESS (&(tattr), &(arinc_threads[1]), &(ret)); /* This thread was mapped from a thread component containedin this */ /* process. The function it executes is also generatedin the file */ /* activity.c.*/ CREATE_ERROR_HANDLER (pok_error_handler_worker, 8192, &(ret)); /* One thread inside the partition can raise faults.We start the error */ /* handle to treat these potentialfaults.*/ SET_PARTITION_MODE (NORMAL, &(ret)); /* Now, we created all resources of the process. Consequently,this thread */ /* will not be used any more and it will be keptin a dormant state. By */ /* doing that, we also allow one morethread in this partition*/ return (0); }
/* Entry point */ void main(void){ RETURN_CODE_TYPE retCode; PROCESS_ID_TYPE procMainIdMT; char sal_code[MAX_CAD]; CREATE_PROCESS (&(processTable [0]), /* process attribute */ &procMainIdMT, /* process Id */ &retCode); CHECK_CODE(": CREATE_PROCESS Process Master Test", retCode, sal_code); printf("%s\n", sal_code); /* Start main process ... */ START(procMainIdMT, &retCode); CHECK_CODE(": START Process Master Test", retCode, sal_code); printf("%s\n", sal_code); /* To set the partition in a Normal State */ SET_PARTITION_MODE(NORMAL, &retCode); CHECK_CODE(": SET_PARTITION_MODE ", retCode, sal_code); printf("%s\n", sal_code); }
/* Entry point */ void main(void){ int cnt; char sal_code[MAX_CAD]; RETURN_CODE_TYPE retCode; PROCESS_ID_TYPE procMainIdMT; PROCESS_ID_TYPE procMainId1; PROCESS_ID_TYPE procMainId2; PROCESS_ID_TYPE procMainId3; /* Blackboard definitions and identifier */ BLACKBOARD_DEFINITION blackboardDefinitions[NUM_BLACKBOARDS]; BLACKBOARD_ID_TYPE bbId[NUM_BLACKBOARDS]; /* Process Master_Test is created */ CREATE_PROCESS (&(processTable [0]), /* process attribute */ &procMainIdMT, /* process Id */ &retCode); CHECK_CODE(": CREATE_PROCESS Process Master Test", retCode, sal_code); printf("%s\n", sal_code); /* Process P1 is created */ CREATE_PROCESS (&(processTable [1]), /* process attribute */ &procMainId1, /* process Id */ &retCode); CHECK_CODE(": CREATE_PROCESS Process 1", retCode, sal_code); printf("%s\n", sal_code); /* Process P2 is created*/ CREATE_PROCESS (&(processTable [2]), /* process attribute */ &procMainId2, /* process Id */ &retCode); CHECK_CODE(": CREATE_PROCESS Process 2", retCode, sal_code); printf("%s\n", sal_code); /* Process P2 is created*/ CREATE_PROCESS (&(processTable [3]), /* process attribute */ &procMainId3, /* process Id */ &retCode); CHECK_CODE(": CREATE_PROCESS Process 3", retCode, sal_code); printf("%s\n", sal_code); /* To init blackboards */ strcpy (BLACKBOARD_NAME_0, "blackboard1"); strcpy(blackboardDefinitions[0].name, BLACKBOARD_NAME_0); blackboardDefinitions[0].msgSize = 3; strcpy(BLACKBOARD_NAME_1, "blackboard2"); strcpy(blackboardDefinitions[1].name, BLACKBOARD_NAME_1); blackboardDefinitions[1].msgSize = 3; /* Blackboard B1 and B2 are created and clear */ for (cnt = 0; cnt < NUM_BLACKBOARDS; cnt++){ bbId [cnt] = -1; retCode = -1; CREATE_BLACKBOARD (blackboardDefinitions[cnt].name, blackboardDefinitions[cnt].msgSize, &bbId[cnt], &retCode); CHECK_CODE(": CREATE_BLACKBOARD", retCode, sal_code); printf("%s %s\n", sal_code, blackboardDefinitions [cnt].name); CLEAR_BLACKBOARD(bbId [cnt], &retCode); CHECK_CODE(": CREAR_BLACKBOARD", retCode, sal_code); printf("%s %s\n", sal_code, blackboardDefinitions [cnt].name); } /* Start main process ... */ START(procMainIdMT, &retCode); CHECK_CODE(": START Process Master Test", retCode, sal_code); printf("%s\n", sal_code); /* To set the partition in a Normal State */ SET_PARTITION_MODE(NORMAL, &retCode); CHECK_CODE(": SET_PARTITION_MODE ", retCode, sal_code); printf("%s\n", sal_code); return; }