13.07.2015 Views

Embedded Systems I, DVA316 Västerås, 2013-01-09

Embedded Systems I, DVA316 Västerås, 2013-01-09

Embedded Systems I, DVA316 Västerås, 2013-01-09

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1(7)(Till tentamensvakten: engelsk information behövs)Exam<strong>Embedded</strong> <strong>Systems</strong> I, <strong>DVA316</strong>Västerås, <strong>2<strong>01</strong>3</strong>-<strong>01</strong>-<strong>09</strong>Teacher: Damir Isovic, tel: 021-103173Exam duration: 08:10 – 12:30Help allowed:Points:language dictionary and APPENDIX 1 attachedto this exam.45 exam points + lab pointsGrading: Swedish grades: ECTS grades:< 28 à failed < 28 à failed28 – 37 p à 3 28 – 33 à D38 – 45 p à 4 34 – 39 à C46 – 50 p à 5 40 – 45 à B46 – 50 à AInstructions:• Answers may be written in English or Swedish.• Short and precise answers are preferred. Do not write more thannecessary.• If some assumptions are missing, or if you think theassumptions are unclear, write down what do you assume tosolve the problem.• Write clearly. If I cannot read it, it is wrong.Good luck!!


2(7)Assignment 1: (9 points)Give short and precise answers to the following questions:a) What is an embedded system? Give two examples. (1p)b) Explain briefly each of the following characteristics of embedded systems (4p):• Specialized• Reactive• Dependable• Real-timec) C-language has several features that make it suitable for programming embeddedsystems. Describe shortly two such features. (2p)d) There are several requirements that affect the design of embedded systems.Describe shortly two such requirements. (2p)Assignment 2: (9 points)The figure below is a simplified schematic view of the microcontroller used in the labs of thiscourse. Explain briefly each of the marked components (9p):JTAG (2p)SRAM (2p)RTC (3p)GPIO (2p)


3(7)Assignment 3: (9 points)Assume two periodic tasks τ 1 and τ 2 that communicate to each other by sending messagesbetween their instances. The following is given:Task τ 1 :• Has execution time 200 ms and period 500 ms.• Sends 3 messages to a message queue MSGQ during each instance (job).• Has low priority.Task τ 2 :• Has execution time 100 ms and a period 300 ms.• Receives 2 messages during each instance (job).• Has high priority.MSGQ:• The queue contains the copy of the messages (not pointers).• Has FIFO order for inserting the messages.• When a task reads a message from the message queue, the message is removedfrom the queue.Questions:a) Assume that τ 1 sends all three messages at the end of its execution. What is theminimum possible size of the message queue (counted in number of messages) suchthat we are able to guarantee there will always be enough space in the queue for τ 1 toinsert its messages? (Hint: draw an execution trace and show when messages aresent). (4p)b) Write a C-code how this task communication can be implemented in FreeRTOS. Youshould provide the code for both tasks and the main function. (Hint: use the systemcalls from the Appendix 1 of this exam). (5p)Assignment 4: (9 points)a) Describe how semaphores can be used to protect a shared resource in a multi-taskingenvironment? How do semaphores work? (1p)b) Explain the terms “priority inversion” and “priority inheritance”, and explain how they relateto each other (2p).c) Consider four tasks, A,B,C,D, that share same resources protected by semaphoresS1,S2,S3,S4. The tasks have different priorities and they are released at different times(see table below). Moreover, all tasks use their semaphores as illustrated in the column“execution sequence” below (clock tick are counted relatively to the release time).


4(7)Task Priority Release time Execution sequenceA 4 (highest) 8 S1 S1 S2 S4B 3 5 S2 S2 S4 S4 S4C 2 2 S2 S2 S1 S3 S3D 1 (lowest) 0 S3 S3 S1Clock tick: 0 1 2 3 4 5 6For example, we can see in the table that task B has the next highest priority, prio(B)=3, itis released at time t=5, and, once when it is released, it will execute like described below:• tick 5+0: executes one clock tick without any semaphores.• tick 5+1: tries to lock S2, and if ok, it enters its critical section with S2• tick 5+2: continues to run with S2 and then releases it at the end of the tick.• tick 5+3: tries to lock S4, and if ok, it enters its critical section with S4• tick 5+4: continues to execute with S4 locked• tick 5+5: continues to execute with S4 locked, and when done it releases it.• tick 5+6: executes one tick without any semaphores.The same reasoning applies to all other tasks.Note that the execution scenarios for the tasks will be equal to the ones illustrated in thetable above only under the assumption that the required semaphores are free whenrequested by a task, and the task is not pre-empted by a high-priority task. However, fromthe release times above we can see that the task will interfere with each other, e.g., task Cwill preempt task D at time t=2, task B will preempt task C at time t=5, and task A willpreempt B at t=8. Besides, the semaphores may be in use when requested by tasks,which would cause blocking.One way to order the usage of the semaphores is to use Priority Ceiling Protocol. Yourassignment is to show how PCP operates on the tasks and semaphores above, i.e., youneed to draw the actual execution trace for all the tasks if PCP is used, assuming the taskpriorities, release times and the execution sequences from the table above. You should runyour trace from time t=0 until all of the tasks has completely executed once their executionsequences. (6p)Assignment 5: (9 points)a) Explain the difference between static priority and dynamic priority scheduling. (1p)b) Assume the following periodic task set (with all values given in milliseconds). Choose anappropriate static priority scheduling policy covered in the course and investigate theschedulability of the task set by drawing an execution trace. If the task set is notschedulable, investigate if it is possible to make it schedulable either by reducing theexecution time of task C, or by making the period of task A longer (4p).


5(7)Task Execution time Deadline PeriodA 2 5 6B 2 4 8C 4 8 12c) Assume the following periodic task set (with all values given in milliseconds). Choose anappropriate dynamic priority scheduling policy covered in the course and investigate theschedulability of the task set by drawing an execution trace. If the task set is notschedulable, investigate if it is possible to make it schedulable either by reducing theexecution time of task B, or by making the period of task C longer (4p).Task Period Deadline Execution timeA 10 10 7B 20 20 4C 1 1 0.4


6(7)Appendix 1 – FreeRTOS API reference• xTaskHandle• xTaskCreate• vTaskDelete• vTaskDelay• vTaskDelayUntil• uxTaskPriorityGet• vTaskPrioritySet• vTaskSuspend• vTaskResume• vTaskResumeFromISR• xTaskGetTickCount• xTaskGetTickCountFromISR• uxTaskGetNumberOfTasks• vTaskList• vTaskGetRunTimeStats• vTaskStartTrace• usTaskEndTrace• uxTaskGetStackHighWaterMark• xTaskCallApplicationTaskHook• taskYIELD• taskENTER_CRITICAL• taskEXIT_CRITICAL• taskDISABLE_INTERRUPTS• taskENABLE_INTERRUPTS• vTaskStartScheduler• vTaskEndScheduler• vTaskSuspendAll• xTaskResumeAll• xTaskCreateRestricted• vTaskAllocateMPURegions• xQueueCreate• xQueueSendToFront• xQueueSendToBack• xQueueSend• xQueueGenericSend• xQueuePeek• xQueueReceive• xQueueGenericReceive• uxQueueMessagesWaiting• vQueueDelete• xQueueSendToFrontFromISR• xQueueSendToBackFromISR• xQueueSendFromISR• xQueueGenericSendFromISR• xQueueReceiveFromISR• vSemaphoreCreateBinary• xSemaphoreTake• xSemaphoreTakeRecursive• xSemaphoreGive• xSemaphoreGiveRecursive• xSemaphoreGiveFromISR• vSemaphoreCreateMutex• xSemaphoreCreateCounting• xTimerCreate


• pvTimerGetTimerID• xTimerIsTimerActive• xTimerStart• xTimerStop• xTimerChangePeriod• xTimerDelete• xTimerReset• xTimerStartFromISR• xTimerStopFromISR• xTimerChangePeriodFromISR• xTimerResetFromISR• xCoRoutineCreate• vCoRoutineSchedule• crSTART• crEND• crDELAY• crQUEUE_SEND• crQUEUE_RECEIVE• crQUEUE_SEND_FROM_ISR• crQUEUE_RECEIVE_FROM_ISR7(7)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!