Thank you very much RD,

I am trying some combinations for a week and now really feel bad
because even though I read lots of good things on the page of FSM labs
about "shared memory for rtlinux" and started to work on it,  I couldnt
see any example usage of mbuff except "demo.c" of Tomasz
which unfortunately explains nothing about handshaking. Anyway, including
RD's advices below, nothing made "my simple for loops" of user task and
rtlinux thread to share a piece of memory without crashing.

"Approch 1" you wrote below, seems not logical (to me) since the new
shared memory which will be going to be used as a flag between threads is
also a shared memory which needs to be protected(am I right?)

I also tried "Approch 2" (used fifos). But failed again probably because
of that: When forexample user task enters shared area and exits several
times before rtlinux task,and so it (user task) writes several times to
FIFO before rtlinux task reads fifo. So rtlinux task will not read
NULL till it reads all the messages. So , even when the user task is using
memory, rtlinux task thinks that memory is available...
 
any advice?


On Thu, 11 Jul 2002, R O N A L D D U C K wrote:

> There are two ways to address it.
> 
> Approach 1:
> ~~~~~~~~~~~
> Use one more shared memory location in which, Whenever you are going to
> access you write a value and after finishing the writing you make the
> location zero. This way you monitor the location before accessing and if it
> is zero the you start using the memory by writing some value in that common
> memory.
> 
> Pros:
> ~~~~~
>       This is very simple to implement.
> 
> Cons:
> ~~~~~
>       The processor will be occupied unnecessarily because of polling this
> location.
> 
> Approach 2:
> ~~~~~~~~~~~
> Create a two way FIFO in rtlinux and use it for synchronizing. For example
> when ever the rtlinux portion is going to use the memory let it wait on
> reading the FIFO, if FIFO is empty then it shows that the user space is
> using it.  If it is not empty then the memory space is free for your use.
> Vice versa will be for user space.
> Actually whenever you are going to use the memory space first you should
> check your read FIFO if it is having any value you start accessing the
> memory. Once you finish the accessing you write some value to your write
> FIFO. Do the same for both sides. This is applicable only when you have a
> blocking FIFO.
> 
> Pros:
> ~~~~~
>       This way you can reduce the processor occupancy.
> Cons:
> ~~~~~
>       You are dangerously clubbing the real-time with a non real-time portion, so
> assuming the non real-time is dead for whatever the reason after occupying
> the memory, then your real-time portion will never get an opportunity to
> access the memory. Of course, you can eliminate this with a time out.
>       This may bring in an inversion in priority.
> 
> 
> Regards
> RD
> 
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On Behalf Of
> Baskan Kalezade
> Sent: Thursday, July 11, 2002 07:46 P
> To: [EMAIL PROTECTED]
> Subject: [rtl] Mutual Exclusion of Mbuff Shared Area..?
> 
> 
> 
>       I am in trouble trying to share a large structure (with lots of
> pointers in the structure to some other variables) between rtlinux and
> regular linux. When I try to allocate just one memory location (with
> mbuff_alloc) for the main structure name, I got segmantation errors. So I
> allocated memory areas for EACH POINTER variables in the
> structure and now it seems to work fine.(Is it really fine?). Assuming
> allocation is okey, now I want to avoid any collisions forexample
> if rtlinux write the shared area when regular linux is using it.
> 
> Does any one know how to achive mutual exclusion of Mbuff shared memory
> area between rtlinux and regular linux?
> 
> Is there any example of using mutex for the shared memory area?
> 
> Is it easier/logical/possible to use fifo to achive mutual exclusion?
> 
> {b}
> 
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> --
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/
> 
> -- [rtl] ---
> To unsubscribe:
> echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
> echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
> --
> For more information on Real-Time Linux see:
> http://www.rtlinux.org/
> 
> 


-- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
--
For more information on Real-Time Linux see:
http://www.rtlinux.org/

Reply via email to