spellcheck

This commit is contained in:
Laila van Reenen 2025-09-26 17:18:54 +02:00
parent 58432896a4
commit 1ec4500b94
Signed by: LailaTheElf
GPG Key ID: 8A3EF0226518C12D
3 changed files with 21 additions and 17 deletions

Binary file not shown.

View File

@ -56,7 +56,7 @@ int main(void)
} }
``` ```
I measured the resulting frequency with an logic analyser ([[#logic-analiser-view-of-LEDs-for-assignment-31]]; channels are collerd to the led color). It measuerd a period time of $499.568ms$, I call this error could be my cheap logic analyser or en error in the internal oscilator. I measured the resulting frequency with an logic analyser ([[#logic-analiser-view-of-LEDs-for-assignment-31]]; channels are coloured to the led colour). It measured a period time of $499.568ms$, I call this error could be my cheap logic analyser or en error in the internal oscillator.
![Logic analiser view of LEDs for assignment 3.1](https://live.kladjes.nl/uploads/84591270-95b0-4601-aea2-ca44b51adbf9.png) ![Logic analiser view of LEDs for assignment 3.1](https://live.kladjes.nl/uploads/84591270-95b0-4601-aea2-ca44b51adbf9.png)
@ -152,7 +152,7 @@ int main(void)
> C) Why must the flag variable be defined as volatile? > C) Why must the flag variable be defined as volatile?
becouse the compiler doesn't know when `flag` changes. Without `volatile` optimisations can think it does not change at all. because the compiler doesn't know when `flag` changes. Without `volatile` optimisations can think it does not change at all.
## assignment 3.4 ## assignment 3.4
@ -290,13 +290,13 @@ int main(void)
} }
``` ```
Again I validated the timesing with the logicanalyser. Again I validated the timings with the logic-analyser.
![](https://live.kladjes.nl/uploads/16fe6424-cff1-4ce4-b506-7f8d87ec4dc4.png) ![](https://live.kladjes.nl/uploads/16fe6424-cff1-4ce4-b506-7f8d87ec4dc4.png)
## assignment 3.6 ## assignment 3.6
> - reate a copy of the previous project and rename it to opdr_3_6. > - create a copy of the previous project and rename it to opdr_3_6.
> - Using the description of this assignment, define a struct for a “task” and create a global array of 8 empty tasks. > - Using the description of this assignment, define a struct for a “task” and create a global array of 8 empty tasks.
> - Create a function `addTask(...)` to help create a task from a function pointer and other parameters, and add it to the task list (the array) at an appropriate index. > - Create a function `addTask(...)` to help create a task from a function pointer and other parameters, and add it to the task list (the array) at an appropriate index.
> - Create 4 functions to toggle each led separately, these are the functions that will correspond to 4 tasks. > - Create 4 functions to toggle each led separately, these are the functions that will correspond to 4 tasks.
@ -428,9 +428,9 @@ int main(void)
## Assignment 3.7 ## Assignment 3.7
> Now add initial delays5 (in systicks) to your tasks. Use an initial delay of 100, 200, 300, and 400 for green, orange, red, and blue respectively. Make use of a logic analyzer to verify the timing. > Now add initial delays (in systicks) to your tasks. Use an initial delay of 100, 200, 300, and 400 for green, orange, red, and blue respectively. Make use of a logic analyser to verify the timing.
When A task is created, in the version of [[#Assignment 3.7]], the folloing function is used: When A task is created, in the version of [[#Assignment 3.7]], the following function is used:
```c ```c
bool addTask(void (*fn)(void), uint32_t counter) bool addTask(void (*fn)(void), uint32_t counter)
@ -446,9 +446,9 @@ bool addTask(void (*fn)(void), uint32_t counter)
} }
``` ```
Here the `counter` and `counter_rst` menbers are set to the same value. `counter` is the counter that is decremented eacht SysClock. `counter_rst` is the value `counter` is reset to if it reachts 0 after the task is run. Here the `counter` and `counter_rst` members are set to the same value. `counter` is the counter that is decremented each SysClock. `counter_rst` is the value `counter` is reset to if it reacts 0 after the task is run.
Setting `counter` to the initail delay already solves this assignment. The foloing code implements this change. Setting `counter` to the initial delay already solves this assignment. The following code implements this change.
```c {.numberLines} ```c {.numberLines}
#include <stdint.h> #include <stdint.h>

View File

@ -11,15 +11,15 @@
![](https://live.kladjes.nl/uploads/1cdce708-a2e7-4a3d-b727-d5423b892687.png) ![](https://live.kladjes.nl/uploads/1cdce708-a2e7-4a3d-b727-d5423b892687.png)
In the Code it the values for blocking delay are 100, 200, 400, 800 for green, orange, red, blue. The `blocking_delay` function wait for this number of SysTicks, witch is set to $1ms$. I measure delays of $0.4s$, $0.8s$, $1.6s$ and $3.2s$. This is indeed 4x slower of what I would expect on first flance. This delay is becouse this is a preemtive scheduler, the other tasks run in between. There are 4 task all with the same priority, so each task takes 4 time longer. In the Code it the values for blocking delay are 100, 200, 400, 800 for green, orange, red, blue. The `blocking_delay` function wait for this number of SysTicks, witch is set to $1ms$. I measure delays of $0.4s$, $0.8s$, $1.6s$ and $3.2s$. This is indeed 4x slower of what I would expect on first glance. This delay is because this is a preemptive scheduler, the other tasks run in between. There are 4 task all with the same priority, so each task takes 4 time longer.
## Assignment 4.2 ## Assignment 4.2
> A) mplement a non-blocking delay so that a task can request the OS to be kept out of the scheduling loop for a certain number of system ticks. The scheduler should remain preemptive and perform round-robin on all the available(not delayed) tasks. Once the requested number of system ticks have passed, the scheduler should include the task in the selection process. You may use the `taskYield()` function to let the OS know a task is ready to be switched out. > A) implement a non-blocking delay so that a task can request the OS to be kept out of the scheduling loop for a certain number of system ticks. The scheduler should remain preemptive and perform round-robin on all the available(not delayed) tasks. Once the requested number of system ticks have passed, the scheduler should include the task in the selection process. You may use the `taskYield()` function to let the OS know a task is ready to be switched out.
To allow for a non blocking delay the OS sould keep track of the time the to wake it up on the corect time. I did this by adding the new task state `SLEEPING_DELAY` to the enum. To allow for a non blocking delay the OS should keep track of the time the to wake it up on the correct time. I did this by adding the new task state `SLEEPING_DELAY` to the `enum`.
There already is an counter in the task struct. but no function that decrements this counter. So I added the folloing function the the OS. There already is an counter in the task struct. but no function that decrements this counter. So I added the following function the the OS.
```c ```c
void decrement_sleeping_delay() void decrement_sleeping_delay()
@ -41,9 +41,9 @@ void decrement_sleeping_delay()
} }
``` ```
This function is added to the `SysTick_Handeler` before the cudeule is run. So that if the counter is 0 the `decrement_sleeping_delay` makes the task ready again, and waits one more SysTick. This function is added to the `SysTick_Handeler` before the scheduler is run. So that if the counter is 0 the `decrement_sleeping_delay` makes the task ready again, and is directly available for to be scheduled. This makes a delay of 0, wait for the next SysTick.
The `SysTick_Handeler` now look like the folloing The `SysTick_Handeler` now look like the following
```c ```c
void SysTick_Handler(void) void SysTick_Handler(void)
@ -58,7 +58,7 @@ void SysTick_Handler(void)
} }
``` ```
Before stating to write the delay function for the tasks, in the `schedule` funciton the line that sets the current task to ready sould be removed (line 163 in `VersdOS.c`). If the state is chanced during execution of the task, this line reset is at the next try to reschedule ths state back to `READY` so the state will never actualy be changed. Before stating to write the delay function for the tasks, in the `schedule` funciton the line that sets the current task to ready sould be removed (line 163 in `VersdOS.c`). If the state is chanced during execution of the task, this line reset is at the next try to reschedule this state back to `READY` so the state will never actually be changed.
As last the delay function itself. As last the delay function itself.
@ -75,6 +75,10 @@ Now all the line `extern void delay(uint32_t ticks);` can be added to the begin
### Result ### Result
![](https://live.kladjes.nl/uploads/c65810e2-a5fc-48f3-be6b-2f30acc5747a.png) ![logic-analyser measurement of the preemptive scheduler](https://live.kladjes.nl/uploads/c65810e2-a5fc-48f3-be6b-2f30acc5747a.png)
This implementation works, only the delays are a bit off. To make it a nice counter again all delays should be decremented by one (figure [[#logic-analyser measurement of the preemptive scheduler]] shows the output with the original timings, not the decremented ones).
## Assignment 4.3
This implementation works, only the delays are a bit off. To make it a nice counter again all delays should be decremented by one.