Slashdot Mirror


More Effective Use of Shared Memory on Linux

An anonymous reader writes "Making effective use of shared memory in high-level languages such as C++ is not straightforward, but it is possible to overcome the inherent difficulties. This article describes, and includes sample code for, two C++ design patterns that use shared memory on Linux in interesting ways and open the door for more efficient interprocess communication."

4 of 280 comments (clear)

  1. Fascagats Post by Adolf+Hitroll · · Score: -1, Offtopic

    Le cochon dans le maïs

    Demain, je porte plainte contre l'Amérique
    J'ai bouffé du maïs et du chou transgénique
    Je n'bande plus ça reste mou comme une chique
    José Bové a dit que c'était allergique
    Il paraît qu'on est plusieurs dans le le même cas-ca
    On ira plus manger au Ricain car c'est caca

    Le seul remède c'est une assiette de foie gras
    Un verre de rouge, du Roquefort et pas de soda
    Demain, je porte plainte contre l'Amérique
    L'Amérique
    Nous ce qu'on veut c'est du bon et du biologique
    Attends tu vas voir, on va leur faire la nique
    Faire la nique
    Si les Ricains nous embrouillent con:

    On leur mettra le cochon
    Le cochon dans le maïs
    Et on mettra les glaçons
    Les glaçons dans le pastis
    {x4}

    Demain, je porte plainte contre L'Amérique
    J'ai bouffé du poireau transformé génétique
    Et depuis ma carotte n'est plus énergique
    Pourtant ma femme tu verrais comme elle l'astique
    Il paraît qu'on est plusieurs dans le même cas-ca

    On ira plus manger au Ricain car c'est caca
    Le seul remède c'est une assiette de foie gras
    Un verre de rouge, du Roquefort et pas de soda
    Demain, je porte plainte contre l'Amérique
    L'Amérique
    Nous ce qu'on veut c'est du bon et du biologique
    Attends, tu vas voir, on va leur faire la nique
    Faire la nique
    Si les Ricains nous embrouillent con:

    On leur mettra le cochon
    Le cochon dans le maïs
    Et on mettra les glaçons
    Les glaçons dans le pastis
    {ad libitum}

    --
    Smile, don't click...
  2. Memory Cache by GoodOmens · · Score: 1, Offtopic
    For those interested the livejournal people released a while ago their source code for memory cache.

    Imemcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

  3. Re:C++ has bigger memory issues by LarsWestergren · · Score: 1, Offtopic

    Java, in which everything is an object except for primitives and it takes ten classes and wrappers just to read a file,

    Eh?

    File inputFile = new File("temp.txt");
    FileReader in = new FileReader(inputFile);

    Or if you want to use the new IO library from 1.4 which gives you memory mapping and locking on sections of files,

    FileChannel in = new FileInputStream("temp.txt").getChannel();

    --

    Being bitter is drinking poison and hoping someone else will die

  4. PHP Shared Memory by GreySkull · · Score: 1, Offtopic

    Hi!
    I have a prob with shared memory in PHP and C++ I thought the /. crowd would help me...

    I have a server written in C++ and my webpages are in PHP. The PHP has to communicate with the server using shared memory. This was working fine on the server running FC-1 with php-4.3.8. We recently migrated to CentOS 4.1 (Equivalent to RHEL 4.1) running php-4.3.9. The error it displays is as follows:

    shmop_open(): unable to attach or create shared memory segment in /var/www/html/sharedmem.php on line 2

    The server opens the shm in 666 (originally was 644) even then it was not working. I can see the shared mem open using 'ipcs' command.

    The source code of PHP is as follows:

    "; // These are fine

    # print $shm_key;

    $shm_id = shmop_open($shm_key, "a",0,0) or die("FATAL ERROR:: Unable to Access Shared Memory"); /*$shm_size = shmop_size($shm_id);
    DEBUG:: print ("Shared Memory Block Size: " . $shm_size."\n");
    */ // Now lets read the string back
    $data = shmop_read($shm_id, 0, $shm_size);
    if (!$data) {
    echo "FATAL ERROR:: Couldn't read from shared memory\n";
    exit;
    }
    ?>

    Both the configs say that 'shmop' is enabled.

    Can some one help me with this, I am in desperate need of this, if this fails I might have to search for an alternative and the project has to go live in a week or so. I am in desperate need of help, can any one help pls?

    Regards,
    Yaswanth