Shared Memory

This is a discussion on Shared Memory within the Linux Programming forums, part of the Platform Specific Boards category; I'm just looking for a little info on the differences between IPC and POSIX shared memory segments. I assume, as ...

  1. #1
    Registered User
    Join Date
    Oct 2005
    Posts
    3

    Shared Memory

    I'm just looking for a little info on the differences between IPC and POSIX shared memory segments. I assume, as with most things, POSIX will be the eaiser to impliment. However, I am looking for the most control over these memory segments as possible and simplicity is not a necessity.

    Furthere more, do either of these implimentations allow for changes in the segment size after creation. I wish to start putting some dynamically sized lists into shared memory and be able to identify when the segment is full and grow accordingly.

    I appreciate any insight that might come my way on this issue.

    Jeremy Warden

  2. #2
    cwr
    cwr is offline
    Registered Luser cwr's Avatar
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    868
    This should probably be moved to the Linux Programming forum, shared memory isn't a feature provided by the C language, it's a platform specific implementation.

    That said, IPC stands for "Interprocess Communication". It's a generic term referring to the set of methods used to communicate between two processes, such as via a socket, a pipe, shared memory, signals, rpc, fifos, et cetera. I'm not sure what you mean by "differences between IPC and POSIX shared memory segments". Perhaps you meant SYSV and POSIX?

    Anyway, I'm not sure if either of them allow a size change.

  3. #3
    .
    Join Date
    Nov 2003
    Posts
    307
    IPC means Interprocess Communication, it's not a standard like POSIX.

    Your question is very broad. I don't know what control means - controlling type of access?
    Synchronization that uses Mutexes/semaphores? What you should seriously consider is reading :

    Chapter 15 in 'Advanced Programming in the UNIX Environment' by R Stevens.

  4. #4
    Registered User
    Join Date
    Oct 2005
    Posts
    3
    Ok then, let me rephrase a bit.

    My question was geared toward fining out what people preferred to use when doing a great deal of work with shared memory and any tricks that have helped them organize their implimentations.

    By "the differences between IPC and POSIX shared memory segments" I simply meant does POSIX bring anything to the party that really makes it usefull.

    The point of posting to a message board like this is not get my post blasted and told to go look in a textbook. Rather to get some insight that isn't in the books and hear what your opinions are.

    Jeremy Warden

  5. #5
    .
    Join Date
    Nov 2003
    Posts
    307
    Short answer: yes. However you need to let the requirements of your application dictate what approach you should use, not what one of here thinks is more interesting or cool or has better features.

    For example, does it have to be portable? - if so, then POSIX compliance is your only hope to ameliorate painful migration or even more painful multi-platform development.

  6. #6
    Registered User
    Join Date
    Oct 2005
    Posts
    3
    Cool was not the question!!! Once again I have discovered the uselessness of messageboards. I am a well educated programmer simply asking for a bit of discussion about experiences and opinions.

    I am very aware that situation dictates implimentaion.

    So if you people want to stop telling me how dumb my question is. Here is some more detail about my 'situation'

    I work with a suite of processes that were developed in the 1980s and are slowly being revamped. All of these process interact with an oracle database. While most of our code has been modernized, many of the background workings still pass info between each other using tables in the databse. This is very timne consuming and as the rest of our software has reached a very efficient state, these countles Pro C sql queries have become a burden to the whole system.

    Shared memory has been used many in many places but only for small sets of static sized data. The advantage of using the Oracle tables is they are inhearently dynamic in size.

    My current project is to migrate as many of these database sharing situations into more usefull shared memory segments. I need to write a library that monitors the segments and the data within them allowing for chages in the segment sizes as well as just providing basic attaching, dettaching, creation and destruction.

    This being my situation I am just asking for some thoughts about how to approach this. I certainly have my own ideas I just find it usefull to have several points of view on a project so that I may see problems before they arise.

    J Warden

  7. #7
    .
    Join Date
    Nov 2003
    Posts
    307
    There are a lot of posts here from folks who can't spell C.

    I think if you had put paragraphs 4 & 5( fronm your last post) in at the start, we could have skipped the other crud.

    If information is being passed as you describe, will message queues meet your needs?
    There are fewer restrictions with this approach than others.

    Shared memory is not dynamic, memory mapped files are dynamic. Memory mapped files have one problem, the memory they reference is generally limited to the process (and it's children) that created the memory mapping for the file. File mappings do not persist across exec calls, so forget that.

    We are Oracle, we use shared memory for some things. If we require dynamic allocations it has to be files (named pipes), pipes, message queues. Message q's are the fastest choice here. If you're on FreeBSD message q's have pretty strict limits on the number of messages in a given queue. In general, the implementation of message q's is quite variable, even though there are "POSIX" standards they are supposed to comply with.
    Linux is good about message queues IMO, while MacOs does not support 'em at all, AFAIK.

    YMMV.

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    Moved.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,546
    > Once again I have discovered the uselessness of messageboards.
    If you want many more professionals then try www.tek-tips.com
    This board is largely aimed at students who are just starting out, so there are in fact very few seasoned pro's here, and even less who could offer a meaningful opinion.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Partly shared memory
    By DrSnuggles in forum C++ Programming
    Replies: 13
    Last Post: 01-21-2009, 02:35 AM
  2. Shared Memory semaphores?
    By Ironic in forum C Programming
    Replies: 0
    Last Post: 10-31-2008, 07:13 PM
  3. Shared memory implementation using thread
    By kumars in forum C Programming
    Replies: 5
    Last Post: 06-18-2008, 04:24 AM
  4. Managing shared memory lookups
    By clancyPC in forum Linux Programming
    Replies: 0
    Last Post: 10-08-2003, 04:44 AM
  5. Shared memory in Linux: B-TREE of structures
    By zahid in forum Linux Programming
    Replies: 3
    Last Post: 01-26-2002, 10:15 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21