Does my description match with our problem ?FFT time depends on speed of the processor, efficiency of the algorithm, fixed point or floating point arithmetic, size of the CPU register and data, and length of the array.
We can pick any number, for example 20ms to process a 1024-word array.
Thanks for the correction.No.
Task 2 runs as often as possible. It takes 20ms. It has the lowest priority.
I wanted to see how you will schedule all three tasks. I was trying this from post #1 on how to schedule tasks in the preemptive multitasking. I don't understand even after trying a lotServicing the ADC every 10μs is a priority task. However this is interrupt driven and not considered as multitasking.
Hardware tasks such as servicing DAC, ADC, timers, UART, SPI, SCI, I2C, USB, etc. are generally all interrupt driven events.
As long as the interrupt handlers can service the interrupt and return control as quickly as possible, these do not need to be scheduled by an RTOS scheduler.
When multiple tasks require considerable CPU processing then one needs to consider scheduling or round-robin processing.
For example, one task needs to read the contents of a disk file, another task tries to write to another file, data is being processed, the screen needs updating, etc.
The bottom line is, on a single core CPU, you have only so much processing time available. If the total time required by all tasks exceeds the amount of available CPU time then there will be a backup in the queue and delays are inevitable. That's life on a computer.
FreeRTOS has lots of tutorial information.I wanted to see how you will schedule all three tasks. I was trying this from post #1 on how to schedule tasks in the preemptive multitasking. I don't understand even after trying a lot
It is very difficult for me to write code without understanding basics so I try to understand concepts how it works. if i understand basic i can try to write my code. Only then can I use the simulator to check the result.Use the simulator to see how the tasks work and get scheduled. It is very difficult to get in depth knowledge of a topic this broad without actually working with it hands-on.
Just my opinion.
@MrChipsUnderstanding Mulitasking
Let us assume that Task-A takes 3 seconds to complete and Task-B takes 2 seconds.
Multitasking or no multitasking, it still takes 5 seconds for both tasks to be completed.
Multitasking gives the illusion of multiple tasks being performed simultaneously.
For example, if Task-A is outputting a 3-second sound bite while Task-B is printing a page, both tasks might be completed in 3 seconds only if there is available processing time for the processor to be time-shared.
If Task-A requires 3 seconds of 100% CPU time and Task-B needs 2 seconds, then round-robin scheduling will still take 5 seconds for both to be completed.
If Task-A takes 3 seconds but only uses 33% of CPU time, this leaves 2 seconds for Task-B to be processed.
In this case cooperative multitasking means than when Task-A is not doing anything useful, Task-B can proceed.
Preemptive multitasking means that a task of higher priority can take access to the CPU away from a lower priority task.
The requirement here is that the high priority task should be processed very quickly, i.e. it consumes a very small percentage of CPU resources. You do not use a scheduler for this.
For example, assume Task-A is to play a 3-minute song. The output DAC interrupts the computer every 25μs but it only uses 1μs of CPU time, i.e. the load on the computer is 4%. (This is not how it is done but I am only using this as an example. See below*) 96% of the CPU time is still available for other tasks to use over the 3-minute period.
Now let us make it much more complex. The computer needs to read a 10MB compressed file from the disk, decompress the video data and the audio data, and output real-time audio and video without missing a beat. Assuming visual flicker rate is 25Hz, the screen must be updated every 20ms, for example. Thus you need to do the time analysis and determine how to do all tasks under 20ms. If it takes longer than 20ms, display and/or sound performance will suffer.
Multitasking is effective when high priority tasks can be processed very quickly, e.g. ADC, DAC, timer, keyboard events, and when time consuming tasks have or allow intermittent pauses, e.g. disk file access, screen updates.
*Many hardware services such as sound, video, serial interfaces, USB, internet access, file access, etc. take advantage of interrupts, DMA (direct memory access) and buffering for enhanced performance. For example, instead of the sound card interrupting the CPU every 25μs, it might request 1k of data once every 25ms. Data is transferred to a memory buffer using DMA. Data is also sent out to the DAC using DMA. Thus the total interaction with the CPU could be a handful of instructions once every 25ms.
as far as I understand, To design preemptive multitasking we need to know the followingNo. You have this wrong.
I have given you a hypothetical example.
Multitasking is all about time management, i.e. how you make free time available for other tasks to use.
No, you do not have to know any of those things to design a multitasking system.as far as I understand, To design preemptive multitasking we need to know the following
- Task execution time
- Task deadline time
- Task priority
Ok i try again, Here is our hypothetical example
Task 1 runs once for 1us every 10us. Highest priority
Task 2 runs once every 20ms. Lowest priority
Task 3 runs once for 1ms every 17ms . Middle priority.
What should be the execution time of Task 2 in the hypothetical situation ?
i'm completely lost. I mentioned preemptive multitasking. As far as I understand, preemptive multitasking requires knowing task execution time, task priority and task deadline time. I guess you are referring to cooperative multitasking.No, you do not have to know any of those things to design a multitasking system.
I’ve kept quiet because I’m not as familiar with preemptive multitasking, but I do know that you don’t need to know all those things you mention.i'm completely lost. I mentioned preemptive multitasking. As far as I understand, preemptive multitasking requires knowing task execution time, task priority and task deadline time. I guess you are referring to cooperative multitasking.
That’s the definition. It preempts a task to let another run. Nothing about length, priority or deadline.A preemptive system can switch tasks anywhere in their execution, between any two instructions.
0
5ms ------> Task 3 is running because it has highest priority
10ms -----> Task 2 is running because it is next high priority task
15ms -----> Task 3 running, Task 2 is interrupted by Task 2 before it has finished