Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Just to inform you that some parts says about explanation which must also be in

ID: 3906401 • Letter: J

Question

Just to inform you that some parts says about explanation which must also be in C language.

Question3 A Real Time Operating System (RTOS) is often used for embedded systems to simplify complex designs while maintaining reliability. A RTOS usually allows for multiple task priarity levels and is preemptive. An example application using the CMSIS-RTOS framework is shown in the following code fragment osThreadId nyTask01Handle osThreadId nyTask02Handle sMutexId myMutex01Handlei / Mutex for common resource int 32 t Counter0 Common resource used by both tasks void StartTask01 (void constargunent) int 32_t while (1) osMutexkait (myMutex01Handle, osWaitForever) LocalCounter ++Counteri Increment and make local copy osMutexRelease (myMutex01Handle) void StartTask02 (void constargunent) while (1) osMutexkait (myMutex01Handle, osWaitForever) LocalCounter-Counteri / Decrement and make local copy osMutexRelease (myMutex01Handle) void main) osKernelinitialize osMutexDef (myMutex01) myMutex01 Handle = osMutexc reate (osMutex (myMutex01)) ; osThreadDef (myTask01, StartTask01, osPriorityNormal, , 256) nyTask01HandleosThreadCreate (osThread (nyTask01),NULL) osThreadDef (myTask02, StartTask02, osPriorityNormal, , 256) nyTask02HandleosThreadCreate (osThread (nyTask02),NULL) osKernelstart D The following questions relate to the code fragment above Page 8 of l2 ELEC3730 Digital and Computer Electronics 2 Practice Esamination a) If the common resource was also required by an Interrupt Service Routine (ISR), could the following code fragment be used inside the ISR? osMutexWait (nyMutex01Handle oskaitForever) LocalCounter--Counter: 1/ Decroment and make local copy osMutexRelease (nyMutex01 Handle) Provide an explanation for your answer b) Explain how the example application could be modified so that only one task procedure is required, yet still achieve the same outcome, with one task incrementing the common resource and the other task decrementing the common resource. No code is required, just an explanation

Explanation / Answer

a) The above code is not advised to use in an ISR because it contains a syncronization
call (mutex operation).Generally mutex makes sense for threads and processes to suspend
or run but ISR is not actally consiered a process or thread (syncroniation call does
not make much sense) plus we generally want ISRs to be very fast in response.


b) Currently here we have two tasks, one is incremneting counter and the other is
decrementing the counter. We can have a single task procedyre and a global varaible
whose value can be checked for incrementig or decrementing the counter.May be we
can increment the global variable by 1 and check if it is even, incease the counter and
if it is odd, decrease the counter.