Jake Blog 2
RTOS Program RRR
Program 1:
Program 1 is the simplest program showing multiple tasks working at different times with task 1 having the longest spread.
Program 1 is the simplest program showing multiple tasks working at different times with task 1 having the longest spread.
I noticed task 3 and 4 were hard to read so i decided to seperate them better as its hard to see when the program is running. As we can see now below its quite easier to read with the only change I made to the code was: Line 52 "printf("\t\t\t4\n\r");" (added another \t to the start of the line)
Program 2:
Program 2 counts how many times Task 1 has been itterated. Once it has reached the count of 5 the program is then terminated. For this I simply increased the counter to 10 to prove that it does end on count.
Program 3:
Program 3 enables/disables tasks on a counter basis to demonstrate its functionalilty. Right now for task 1 when the counter==5, it disables task 3 and when task 2's counter==10, it enables task 3 again forever looping like this.
The modification I made to this was to add another another string of text to show what state task 3 is in along with the count number for an easier read:
Program 4:
Program 4:
Program 4 simply counts how many messages are being recieved by each task. So for the code:
void The_second_rtos_task ( ) {
rtos_msg_send(The_first_rtos_task,count);
if(rtos_msg_poll ( )>0){
printf("messages recieved by task2 : %i\n\r",rtos_msg_read ( ));
count++;
}
}
The rtos_msg_poll looks at how many messages are being recieved and if its greater than 0 it will print how many messages are there. While also sending messages to another task with an incrementing counter so both tasks are constantly being sent new messages with an increasing counter or recieved messages.
Since this constantly runs I decided to terminate the program once it reaches a certain amount of messages so it can "deal with" the messages it already has, so in this case I set a counter within Task 1 so when it reaches a count of 50 it disables Task 2 which in return will stop Task 1 like so:
Program 5 uses a yield function to break out of a given task at a certain point to go do something else and will then return to that exact point after the "something else" is complete, and will continue where it left off.
To demonstrate this I made this easier to see as follows to show it leaving and returning to the tasks via the yield.
Program 6 simply loops through task 1, at the end it will call a yield to task 2 which will only run when task 1 has completed its loop so it goes back to task 1. Once complete it will go run task 2. As seen in the video below we can see task 1 runs much slower than task 2 on the LCD due to the yield.
A simple change i made to this code was by adding a "Task 2 Ready" prompt to show that Task 2 is ready to be deployed as seen in the video below.
Program 7:
Program 7 uses an await function that requires a task to only be enabled when a certain condition is met so in this program the condition is for the count to be equal to 5 before it can start running its task. A change I made is similar to the previous program where I show that the task is now ready to be uses by showing "Task 1 Enabled" and I increased the delay timer so its easier to see Task 1 running.
Program 8:
Program 8 uses statisical functions to show how long a task has ranf for including the minimum time and maximum time it ran for and includes the total amount of ticks used. The second task uses an overrun fuction which will slowly overrun the task to increase the time it takes to complete and will print out a message saying "The second Task has Overrun".
My itteration just takes the difference between the Minimum and Maximum number of ticks and displays it onto Putty as seen below.
Program 9:
Program 9 mimics a Kernal interface that uses commands to run a certain task for example "enable1" essentially turns on / off (if disable1 is entered). If an unknown command is entered a message pops up saying that an unknown command has been entered as seen below.
My iteration or review of the code added a help function that displays all of the avalible commands so the user has an easier time seeing and knowing what commands are avaliable to them
Comments
Post a Comment