/* -----------------------------------------------------------------------------------*/ void Process2(void){ printf("Process 2 starts ...\n"); STOP_SELF(); }
/* -----------------------------------------------------------------------------------*/ void Process1(void){ char sal_code[MAX_CAD]; RETURN_CODE_TYPE retCode; PROCESS_ID_TYPE procMainId2; PROCESS_ID_TYPE procMainId3; printf("Process 1 starts ... \n"); /* To get the procMainId2 value */ GET_PROCESS_ID("tProc2", &procMainId2, &retCode); CHECK_CODE(": GET_PROCESS_ID Process 2", retCode, sal_code); printf("%s\n", sal_code); START(procMainId2, &retCode); CHECK_CODE(": START Process 2", retCode, sal_code); printf("%s\n", sal_code); /* To get the procMainId3 value */ GET_PROCESS_ID("tProc3", &procMainId3, &retCode); CHECK_CODE(": GET_PROCESS_ID Process 3", retCode, sal_code); printf("%s\n", sal_code); START(procMainId3, &retCode); CHECK_CODE(": START Process 3", retCode, sal_code); printf("%s\n", sal_code); /* Process P1 pre-empts Process P3 */ STOP_SELF(); }
/* -----------------------------------------------------------------------------------*/ void Process1(void){ PROCESS_ID_TYPE procMainId2; struct suspend_error_type s_e; RETURN_CODE_TYPE retCode; char sal_code[MAX_CAD]; printf("Process 1 starts ...\n"); /* To get the procMainId2 value */ GET_PROCESS_ID("tProc2", &procMainId2, &retCode); CHECK_CODE(": GET_PROCESS_ID Process 2", retCode, sal_code); printf("%s\n", sal_code); START(procMainId2 ,&retCode); CHECK_CODE(": START Process 2", retCode, sal_code); printf("%s\n", sal_code); /* TIMED_WAIT(REGULAR_TIME_WAIT, &retCode); CHECK_CODE(": TIMED_WAIT", retCode, sal_code); printf("%s\n", sal_code); */ s_e = checksuspend(procMainId2, NO_ERROR); show_result(s_e); STOP_SELF(); }
/* -----------------------------------------------------------------------------------*/ void ProcessMT_Master(void){ LOCK_LEVEL_TYPE lock; APEX_BYTE data[MAX_LENGTH]; long int len; RETURN_CODE_TYPE retCode; PROCESS_ID_TYPE procMainId1; char sal_code[MAX_CAD]; PARTITION_STATUS_TYPE statusp; BLACKBOARD_ID_TYPE bbId; printf("Process Master starts ...\n"); GET_PARTITION_STATUS(&statusp, &retCode); CHECK_CODE(": GET_PARTITION_STATUS", retCode, sal_code); printf("%s\n", sal_code); /* Make sure the preemption is enabled, lock == 0 */ if (statusp.LOCK_LEVEL>0){ UNLOCK_PREEMPTION(&lock, &retCode); while (lock!=0){ UNLOCK_PREEMPTION(&lock, &retCode); } }else if (statusp.LOCK_LEVEL<0){ LOCK_PREEMPTION(&lock, &retCode); while (lock!=0){ LOCK_PREEMPTION(&lock, &retCode); } } /* To get the procMainId1 value */ GET_PROCESS_ID("tProc1", &procMainId1, &retCode); CHECK_CODE(": GET_PROCESS_ID Process 1", retCode, sal_code); printf("%s\n", sal_code); START(procMainId1 ,&retCode); CHECK_CODE(": START Process 1 ", retCode, sal_code); printf("%s\n", sal_code); /* Process P1 pre-empts Master_Test */ /* Call service READ_BLACKBOARD B1 */ GET_BLACKBOARD_ID(BLACKBOARD_NAME_0, &bbId, &retCode); CHECK_CODE(": GET_BLACKBOARD_ID_0 by ProcessMT_Master", retCode, sal_code); printf("%s\n", sal_code); READ_BLACKBOARD (bbId, 0, data, &len, &retCode); CHECK_CODE(": READ_BLACKBOARD B1", retCode, sal_code); printf("%s Read data: %s\n", sal_code, data); /* Call service READ_BLACKBOARD B2 */ GET_BLACKBOARD_ID(BLACKBOARD_NAME_1, &bbId, &retCode); CHECK_CODE(": GET_BLACKBOARD_ID_1 by ProcessMT_Master", retCode, sal_code); printf("%s\n", sal_code); READ_BLACKBOARD (bbId, 0, data, &len, &retCode); CHECK_CODE(": READ_BLACKBOARD B2", retCode, sal_code); printf("%s Read data: %s\n", sal_code, data); STOP_SELF(); }
/* -----------------------------------------------------------------------------------*/ void Process2(void){ APEX_BYTE data[MAX_LENGTH]; RETURN_CODE_TYPE retCode; char sal_code[MAX_CAD]; BLACKBOARD_ID_TYPE bbId; printf("Process 2 starts ... \n"); strcpy(data, "OK"); GET_BLACKBOARD_ID(BLACKBOARD_NAME_1, &bbId, &retCode); CHECK_CODE(": GET_BLACKBOARD_ID_1 by Process2", retCode, sal_code); printf("%s\n", sal_code); DISPLAY_BLACKBOARD (bbId, data, 3, &retCode); CHECK_CODE(": DISPLAY_BLACKBOARD B2 in Process 2", retCode, sal_code); printf("%s\n", sal_code); STOP_SELF(); }
/* -----------------------------------------------------------------------------------*/ void Process3(void){ struct stop_error_type c_s; APEX_BYTE data[MAX_LENGTH]; char sal_code[MAX_CAD]; PROCESS_ID_TYPE procMainId2; RETURN_CODE_TYPE retCode; BLACKBOARD_ID_TYPE bbId; printf("Process 3 starts ... \n"); strcpy(data, "OK"); /* To get the procMainId2 value */ GET_PROCESS_ID("tProc2", &procMainId2, &retCode); CHECK_CODE(": GET_PROCESS_ID Process 2", retCode, sal_code); printf("%s\n", sal_code); /* To check stop process 2 */ c_s = check_stop(procMainId2, NO_ERROR); GET_BLACKBOARD_ID(BLACKBOARD_NAME_0, &bbId, &retCode); CHECK_CODE(": GET_BLACKBOARD_ID_0 by Process3", retCode, sal_code); printf("%s\n", sal_code); DISPLAY_BLACKBOARD (bbId, data, 3, &retCode); CHECK_CODE(": DISPLAY_BLACKBOARD B1 in Process 3", retCode, sal_code); printf("%s\n", sal_code); START(procMainId2, &retCode); CHECK_CODE(": START Process 2", retCode, sal_code); printf("%s\n", sal_code); show_results(c_s); STOP_SELF (); }
void exit(int rc) { STOP_SELF(); }
void pok_error_handler_worker () { ERROR_STATUS_TYPE error_status; RETURN_CODE_TYPE ret; /* The variables error and thread are createdto store the thread-id and */ /* the error-idwhen a fault is raised*/ /* We prefer to force a default value to the variableserror and thread*/ /* Here, we declare the fault handler as ready andthat faulty thread-id */ /* and error-id must be storedin the thread and error variables*/ while (1) { STOP_SELF (); GET_ERROR_STATUS (&(error_status), &(ret)); switch (error_status.FAILED_PROCESS_ID) { case 1: { switch (error_status.ERROR_CODE) { case DEADLINE_MISSED: { pok_error_ignore (DEADLINE_MISSED, 1); break; } case APPLICATION_ERROR: { pok_error_ignore (APPLICATION_ERROR, 1); break; } case NUMERIC_ERROR: { pok_error_ignore (NUMERIC_ERROR, 1); break; } case ILLEGAL_REQUEST: { pok_error_ignore (ILLEGAL_REQUEST, 1); break; } case STACK_OVERFLOW: { pok_error_ignore (STACK_OVERFLOW, 1); break; } case MEMORY_VIOLATION: { pok_error_ignore (MEMORY_VIOLATION, 1); break; } case HARDWARE_FAULT: { pok_error_ignore (HARDWARE_FAULT, 1); break; } case POWER_FAIL: { pok_error_ignore (POWER_FAIL, 1); break; } } break; } /* Here, we declare the error handling mecanisms for the task*/ } } /* IMPORTANT : this main function creates all resources (ports, data, */ /* tasks/threads/processes used by this node*/ }