C Structure in Shared Memory question.

C Structure in Shared Memory question.

Post by S » Sun, 12 May 2002 08:12:13



There's two processes accessing a C structure in shared memory.  Is it
possible for process 1 to write to a particular structure element and
have process 2 to write in a different structure element, at the same
time?  Thanx in advance.
 
 
 

C Structure in Shared Memory question.

Post by Jens.Toerr.. » Sun, 12 May 2002 08:36:59



> There's two processes accessing a C structure in shared memory.  Is it
> possible for process 1 to write to a particular structure element and
> have process 2 to write in a different structure element, at the same
> time?  Thanx in advance.

Could you define more clearly what you mean with "at the same time"?
If you don't have more than one CPUs running the different processes
"at the same time" doesn't make any sense. And even if you have two
CPUs I would guess that most systems don't allow both of them accessing
memory at the same time. But if you mean by "at the same time" that
both processes are allowed to change the shared memory whenever they
want (at least while they are running) I don't see any reason why they
shouldn't, they could even write to the same memory location (of course,
this might lead to lots of very interesting and hard to find bugs ;-)

                                         Regards, Jens
--
      _  _____  _____

  _  | |  | |    | |          AG Moebius, Institut fuer Molekuelphysik
 | |_| |  | |    | |          Fachbereich Physik, Freie Universitaet Berlin
  \___/ens|_|homs|_|oerring   Tel: ++49 (0)30 838 - 53394 / FAX: - 56046

 
 
 

C Structure in Shared Memory question.

Post by Rich Tee » Sun, 12 May 2002 09:46:10



Quote:> There's two processes accessing a C structure in shared memory.  Is it
> possible for process 1 to write to a particular structure element and
> have process 2 to write in a different structure element, at the same
> time?  Thanx in advance.

Sure; it's only when two process/threads want to access the SAME
member that the fun starts.

--
Rich Teer

President,
Rite Online Inc.

Voice: +1 (250) 979-1638
URL: http://www.rite-online.net

 
 
 

C Structure in Shared Memory question.

Post by David Schwart » Sun, 12 May 2002 10:33:22




> > There's two processes accessing a C structure in shared memory.  Is it
> > possible for process 1 to write to a particular structure element and
> > have process 2 to write in a different structure element, at the same
> > time?  Thanx in advance.
> Sure; it's only when two process/threads want to access the SAME
> member that the fun starts.

        Are you really so sure? Consider:

struct
{
 char a;
 char b;
...

        DS

 
 
 

1. Shared Memory using the proc/ structure.

Hi All :
        If a process spawns a child, is it possible for them to communicate using the /proc structure?. Instead of opening up a socket for communication I am trying to use shared memory to do the same and was wondering if /proc could be used to that effect. It it is not possible, then how do I generate a shared memory structure?.
        Your help will be much appreciated.

        -Laxman

2. Shut off & power down?

3. Shared memory and dyamic data structures

4. Is there a reliable GUI ftp client for Linux?

5. Solaris 10: Increasing the process data space; shared memory segments & intimate shared memory problems

6. vgatext console, 80x50, works!

7. Shared Memory,Memory mapped files and Threads

8. HP 9000 Questions

9. How do I use shared memory the same was as the heap memory?

10. AIX Shared Memory Segment (Not enough memory)

11. Device Driver that will allow access to Kernel memory from shared memory?

12. How to check the amount of free memory in share memory

13. semaphors & memory share & object share