Project 4
Due Sunday April 28, 2024 at 11:59PM in Canvas (200 Points)
Objective
To implement resource control algorithms in FreeRTOS.
1 Project Overview
In Project 3, you learned how to implement the rate-monotonic algorithm (RM) in FreeRTOS. For this project, you will leverage your RM implementation to support the priority inheritance protocol (PIP) and priority ceiling protocol (PCP) in FreeRTOS.
As in Project 3, you will validate your implementation through a systemic debugger (in our case the serial port communication).
2 Notes on Implementation of PIP and PCP
In this project, you will implement PIP and PCP for RM (hereafter called RM-PIP and RM-PCP respectively) in FreeRTOS. We have discussed both protocols in class, but addition details can be found in the textbook: PCP is documented in Section 7.7 and PIP is described in Section 7.6.
This project requires a working implementation for rate monotonic (RM) scheduling. Please contact the GTAs if you need one.
3 Tasks & Rubrics
1. (100 points) Implement the RM-PIP scheduling algorithm with the following requirements:
• Your algorithm does not need to perform. any schedulability test. RM-PIP should follow all the rubrics as listed under RM scheduling in Project 3.
• Moreover, in the event that a job fails to acquire the resource within its worst-case execution time, it should be suspended and run as a new job at its next release time. In other words, the current (missed) instance of the task is dropped.
• Use the C Structs to define your shared resources. You are free to use Struct members that will record information pertaining to tasks that acquire it.
• Your code should print out relevant information to the serial monitor, e.g., which task is executing, when it is executing which of its critical sections, if a task misses its deadline, etc.
The key to implementing RM-PIP in FreeRTOS is determining how to inherit the priority of a task/job. You can debug/test your code with an arbitrary task set of your choice.
There are several FreeRTOS APIs that you may find helpful:
• Your first job is to explore how FreeRTOS implements priority inheritance. Consult semphr.h,
queue.c, and queue.h in FreeRTOS/src to further understand how that works.
• xSemaphoreCreateMutex creates a mutex, and returns a handle by which the created mu- tex can be referenced. Mutexes are acquired using xSemaphoreTake, and released using xSemaphoreGive. SemaphoreHandle t stores the handle of a mutex/semaphore. (Hint: Mu- texes and binary semaphores are very similar but have some subtle differences).
• xTaskGetHandle is used to look up the handle of a task from the task’s name. Similarly, xSemaphoreGetMutexHolder returns the handle of the task that holds the mutex specified by the function parameter.
• vTaskGetInfo populates a TaskStatus t structure for just a single task. The TaskStatus t structure contains, among other things, the members for the task handle, task name, task priority, task state, and the total amount of execution time consumed by the task. (Hint: Each task has a member uxBasePriority in FreeRTOS/src/task.h. Check what is it used for.)
• uxTaskPriorityGet/vTaskPrioritySet obtains/sets the priority of a task.
What to include in your report: A description of your RM-PIP implementation. This description should be detailed enough that a competent peer of yours can follow along and implement your work. In addition, you should include justifications as to why your implementation is correct.
2. (100 points) Implement the RM-PCP scheduling algorithm with the same requirements as RM- PIP (see above). Since RM-PCP is an improvement over RM-PIP, it follows similar pattern of execution, with specific changes to decision making while acquiring and releasing the mutex. The key to implementing RM-PCP in FreeRTOS is tracking the highest priority ceiling among all the locked resource(s) on the fly.
What to include in your report: A description of your RM-PCP implementation. You don’t need to repeat information already described under your RM-PIP implementation. Again, you should include justifications as to why your implementation is correct.
4 Turning In Your Work
You are to upload the following documents on Canvas.
• Your report in Word format.
• Your RM-PIP and RM-PCP code.
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。