Difference between blocked and suspended
Posted by Riccardo Manfrin
on May 21, 2013
I would like to resume this post
I'm not familiar with Freertos (complete ignorant newbie), but I do not comprehend the need to differentiate between suspended and blocked states for a task.
If the difference is really just about the presence of a timeout for blocked state, then in my mind, I see a timeout just like any other type of event that is going to release a semaphore for the sake of a suspended routine. It can be a keyboard press, a timeout, or the union of these and several more events.
Therefore, I'd like to know the motivation for supporting these two states. They are reported in documentation and differentiated in APIs, therefore I assume there must be some good reason that I'm missing for them to exist.
Maybe timeout support from the OS ensures RTOSness responsivity, or maybe it guarantees 100% that something will wake up the task, which maybe is not so sure to happen if I had that timeout handled by the carefree hands of a userspace task.. ? Or maybe I'm completely misunderstanding everything at all.
I'd like to understand this aspect of FreeRTOS.
RE: Difference between blocked and suspended
Posted by Westmoreland Engineering
on May 21, 2013
I haven't looked at the previous thread - but I will try to explain to you so this makes sense:
Think of vTaskSuspend ( NULL ); and vTaskResume ( xTaskHandle); as task control mechanisms. When the task is suspended vTaskSuspend ( NULL or xTaskHandle ) has been called.
When a task is waiting on an event - such as a semaphore being available or data from a Queue - and it waits - then it is blocking on that event. Think of this as task synchronization.
So you have two discrete things to think about regarding tasks - control and synchronization. Note these are simple examples but I am trying to get you to think about what you need to do with your tasks.
If you are new to the RTOS world - and it sounds like you are - it will take a little while to get your head around all of this. An RTOS will help you to distribute system resources in an equitable fashion, in either hard or soft real-time. You really need to understand what hard and soft real-time mean. I am sure you can find a lot of explanations of this on the internet.
The best way to learn is by doing - so the more you program and use the RTOS, the more you will learn. By the time you are done, you will understand the differences between blocked and suspended states; filling or waiting on queues, and giving and taking semaphores.
Hope This Helps,
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.