[Pending]Resource sharing in real time embedded systems

Thread Starter

Pushkar1

Joined Apr 5, 2021
414
I still don't fully understand what is resource sharing in real time embedded systems programming. From the discussion I have come to the conclusion that we need RTOS when we need guaranteed response time and when we need to share resources.

I understand that different different tasks can share the microcontroller's peripherals. As a simple example, As I2C is the peripheral of the microcontroller. How do different tasks share I2C

In traditional programming, when multiple devices support I2C protocol, I write functions for i2c protocol. I call these function in main for multiple devices. I share a I2C function for all I2C devices

During this process the protocol is shared for multiple devices. Is this what we call resource sharing process in real time embedded systems programming?
 

Ian Rogers

Joined Dec 12, 2012
952
I'm beginning to think RTOS is NOT!!! for you...

A task can be for device reading, the shared resource can be the output.

Task 1 posts a request for information from a device ( task1 shouldn't care what the device is )
Task 2 reads/ write the device and places the necessary data somewhere, alerts the other task of completion.

When you open a window in windows.. You open a container.. other tasks then use the container, if you view tasks like objects then you can see how you can get them to interact with each other..
 

Papabravo

Joined Feb 24, 2006
17,291
I still don't fully understand what is resource sharing in real time embedded systems programming. From the discussion I have come to the conclusion that we need RTOS when we need guaranteed response time and when we need to share resources.

I understand that different different tasks can share the microcontroller's peripherals. As a simple example, As I2C is the peripheral of the microcontroller. How do different tasks share I2C

In traditional programming, when multiple devices support I2C protocol, I write functions for i2c protocol. I call these function in main for multiple devices. I share a I2C function for all I2C devices

During this process the protocol is shared for multiple devices. Is this what we call resource sharing process in real time embedded systems programming?
I2C is a poor example of a shared resource because tasks cannot use this resource at the same time. The I2C interface is serially reusable so a task which wants the I2C MUST wait it's turn. What it can do is schedule the I2C transaction to be executed at some future time and block itself until the reply is received.
 

click_here

Joined Sep 22, 2020
446
"How do different tasks share I2C"
When threading the way to share a resourse is to use a mutex semaphore.

Basically when one thread uses a resource it changes the state of a special type of variable.

When another thread comes along it checks this variable to see if it can use the resource.

If the resource is in use it will wait until the vaiable has been cleared again, before putting it in a occupied state again.
 

MrChips

Joined Oct 2, 2009
24,620
Shared file system is an example of shared resource.

Be aware of a system lockup problem aka deadly embrace.
Task #1 is using resource A but needs resource B to proceed.
Task #2 is using resource B but needs resource A to continue.
The system will hang forever, very much like grid lock.
 

Thread Starter

Pushkar1

Joined Apr 5, 2021
414
The CPU(s)
List of hardware resources

Timer
Interrupt
Uart
SPI
I2C
ADC
Port Pins
.... And so many

I'm sure they are all resources

Doesn't it mean that different tasks share this resources? What I don't understand is how these resources are shared

Another way can be that I have screen and I am sharing this screen to show data of different sensors.

I have shown two ways I want some clarity while sharing resources which is the right way.
 

BobaMosfet

Joined Jul 1, 2009
1,898
I still don't fully understand what is resource sharing in real time embedded systems programming. From the discussion I have come to the conclusion that we need RTOS when we need guaranteed response time and when we need to share resources.

I understand that different different tasks can share the microcontroller's peripherals. As a simple example, As I2C is the peripheral of the microcontroller. How do different tasks share I2C

In traditional programming, when multiple devices support I2C protocol, I write functions for i2c protocol. I call these function in main for multiple devices. I share a I2C function for all I2C devices

During this process the protocol is shared for multiple devices. Is this what we call resource sharing process in real time embedded systems programming?
@Pushkar1 I2C/TWI is NOT a peripheral, in most MCU architectures. It is a built in resource. so whatever file you write for I2C/TWI comms, would become a comm-file as part of the RTOS kernel, to provide resources, just like time, or events, or anything else core to the RTOS. It only becomes peripheral if it requires a driver to an external piece of hardware (like an ethernet, or RFID adjunct).

If only I could sit down with you in front of a white-board for 1 hour- I blow your mind with how simple RTOS's actually are, and why they are such an elegant solution for almost any embedded project. The savings in reliability alone makes it worth it.
 

Thread Starter

Pushkar1

Joined Apr 5, 2021
414
You have a habit of making generalized statements,

Bob
First of all I researched on internet that what is resource sharing in real time programming. After reading from many sources, I was very confused, so I found two things in which I was confused. and I asked for clarification.
 
Top