Complete lab report
This commit is contained in:
parent
5d5dfe1994
commit
27d4aea3bc
2 changed files with 225 additions and 0 deletions
225
lab3/labReport.md
Normal file
225
lab3/labReport.md
Normal file
|
@ -0,0 +1,225 @@
|
|||
# Experiment Set #3
|
||||
## Exercises 5-8
|
||||
### Blizzard Finnegan
|
||||
|
||||
5. Analyse Access Contention Problems
|
||||
|
||||
```c
|
||||
/*USER CODE BEGIN PV*/
|
||||
int StartFlag = 1;
|
||||
/*USER CODE END PV*/
|
||||
/* USER CODE BEGIN 4*/
|
||||
void AccessFunction(){
|
||||
if(StartFlag == 1){
|
||||
StartFlag = 0;
|
||||
} else {
|
||||
HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_15);
|
||||
}
|
||||
for(int i = 0; i < 2000000; i++);
|
||||
StartFlag = 1;
|
||||
return;
|
||||
}
|
||||
/* USER CODE END 4*/
|
||||
void StartFlashGreenLedTask(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN 5 */
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12,GPIO_PIN_SET);
|
||||
AccessFunction();
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12,GPIO_PIN_RESET);
|
||||
osDelay(500);
|
||||
}
|
||||
/* USER CODE END 5 */
|
||||
}
|
||||
void StartFlashRedLedTask(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN StartFlashRedLedTask */
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_14,GPIO_PIN_SET);
|
||||
AccessFunction();
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_14,GPIO_PIN_RESET);
|
||||
osDelay(100);
|
||||
}
|
||||
/* USER CODE END StartFlashRedLedTask */
|
||||
}
|
||||
```
|
||||
|
||||
6. Eliminate Resource Contention By Suspending the Scheduler
|
||||
|
||||
```c
|
||||
/*USER CODE BEGIN PV*/
|
||||
int StartFlag = 1;
|
||||
/*USER CODE END PV*/
|
||||
/* USER CODE BEGIN 4*/
|
||||
void AccessFunction(){
|
||||
if(StartFlag == 1){
|
||||
StartFlag = 0;
|
||||
} else {
|
||||
HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_15);
|
||||
}
|
||||
for(int i = 0; i < 2000000; i++);
|
||||
StartFlag = 1;
|
||||
return;
|
||||
}
|
||||
/* USER CODE END 4*/
|
||||
void StartFlashGreenLedTask(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN 5 */
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12,GPIO_PIN_SET);
|
||||
taskENTER_CRITICAL();
|
||||
AccessFunction();
|
||||
taskEXIT_CRITICAL();
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12,GPIO_PIN_RESET);
|
||||
osDelay(500);
|
||||
}
|
||||
/* USER CODE END 5 */
|
||||
}
|
||||
void StartFlashRedLedTask(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN StartFlashRedLedTask */
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_14,GPIO_PIN_SET);
|
||||
taskENTER_CRITICAL();
|
||||
AccessFunction();
|
||||
taskEXIT_CRITICAL();
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_14,GPIO_PIN_RESET);
|
||||
osDelay(100);
|
||||
}
|
||||
/* USER CODE END StartFlashRedLedTask */
|
||||
}
|
||||
```
|
||||
|
||||
7. Demonstrate Deterioration in System Performance
|
||||
|
||||
```c
|
||||
/*USER CODE BEGIN PV*/
|
||||
int StartFlag = 1;
|
||||
/*USER CODE END PV*/
|
||||
/* USER CODE BEGIN 4*/
|
||||
void AccessFunction(){
|
||||
if(StartFlag == 1){
|
||||
StartFlag = 0;
|
||||
} else {
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_15,GPIO_PIN_SET);
|
||||
}
|
||||
for(int i = 0; i < 2000000; i++);
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_15,GPIO_PIN_RESET);
|
||||
StartFlag = 1;
|
||||
return;
|
||||
}
|
||||
/* USER CODE END 4*/
|
||||
void StartFlashGreenLedTask(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN 5 */
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12,GPIO_PIN_SET);
|
||||
taskENTER_CRITICAL();
|
||||
AccessFunction();
|
||||
taskEXIT_CRITICAL();
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12,GPIO_PIN_RESET);
|
||||
osDelay(500);
|
||||
}
|
||||
/* USER CODE END 5 */
|
||||
}
|
||||
void StartFlashRedLedTask(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN StartFlashRedLedTask */
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_14,GPIO_PIN_SET);
|
||||
taskENTER_CRITICAL();
|
||||
AccessFunction();
|
||||
taskEXIT_CRITICAL();
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_14,GPIO_PIN_RESET);
|
||||
osDelay(100);
|
||||
}
|
||||
/* USER CODE END StartFlashRedLedTask */
|
||||
}
|
||||
void StartFlashOrangeLED(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN StartFlashOrangeLED */
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_13);
|
||||
osDelay(50);
|
||||
}
|
||||
/* USER CODE END StartFlashOrangeLED */
|
||||
}
|
||||
```
|
||||
|
||||
8. Evaluate priority preemptive scheduling policies.
|
||||
|
||||
```c
|
||||
/*USER CODE BEGIN PV*/
|
||||
int StartFlag = 1;
|
||||
/*USER CODE END PV*/
|
||||
/* USER CODE BEGIN 4*/
|
||||
void AccessFunction(){
|
||||
if(StartFlag == 1){
|
||||
StartFlag = 0;
|
||||
} else {
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_15,GPIO_PIN_SET);
|
||||
}
|
||||
for(int i = 0; i < 2000000; i++);
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_15,GPIO_PIN_RESET);
|
||||
StartFlag = 1;
|
||||
return;
|
||||
}
|
||||
/* USER CODE END 4*/
|
||||
void StartFlashGreenLedTask(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN 5 */
|
||||
uint32_t WaitTimeMilliseconds = 550;
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12,GPIO_PIN_SET);
|
||||
osSemaphoreWait(CriticalResourceSemaphoreHandle,WaitTimeMilliseconds);
|
||||
AccessFunction();
|
||||
osSemaphoreRelease(CriticalResourceSemaphoreHandle);
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_12,GPIO_PIN_RESET);
|
||||
osDelay(500);
|
||||
}
|
||||
/* USER CODE END 5 */
|
||||
}
|
||||
void StartFlashRedLedTask(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN StartFlashRedLedTask */
|
||||
uint32_t WaitTimeMilliseconds = 200;
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_14,GPIO_PIN_SET);
|
||||
osSemaphoreWait(CriticalResourceSemaphoreHandle,WaitTimeMilliseconds);
|
||||
AccessFunction();
|
||||
osSemaphoreRelease(CriticalResourceSemaphoreHandle);
|
||||
HAL_GPIO_WritePin(GPIOD,GPIO_PIN_14,GPIO_PIN_RESET);
|
||||
osDelay(100);
|
||||
}
|
||||
/* USER CODE END StartFlashRedLedTask */
|
||||
}
|
||||
void StartFlashOrangeLED(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN StartFlashOrangeLED */
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
HAL_GPIO_TogglePin(GPIOD,GPIO_PIN_13);
|
||||
osDelay(50);
|
||||
}
|
||||
/* USER CODE END StartFlashOrangeLED */
|
||||
}
|
||||
```
|
BIN
lab3/labReport.pdf
Normal file
BIN
lab3/labReport.pdf
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue