Questions on sem_* and shm_* functions

[email protected] (Sebastian Bergmann) Sat, 17 Jun 2000 16:34:07 +0200
Newsgroups php.dev,php.version4
Message-ID <[email protected]>
Hi there,

  I'm currently working on something I called "phpWin32SxM - A Fake
Implementation of PHP's Semaphore (SEM) and Shared Memory Functions
(SHM) for the Win32 Platform".

  I use SQL tables to emulate "Shared Memory" and Semaphores on
Win32-based machines.

  I'm mostly finished with the shm_* functions. This means, that the
functions do what they're expected to do, for instance the following
code works just fine on my Win32 installation of PHP 4.0.1-dev:

  <?php
    include "phpWin32SxM.php";

    $test = array( "test", "it works" );

    $shm = shm_attach( 123 );
    shm_put_var( $shm, "test", $test );
    $test2 = shm_get_var( $shm, "test" );
    shm_remove_var( $shm, "test" );
    shm_remove( $shm );

    print $test2[1];
  ?>

  The output is, as expected, "it works".

  But I have some questions about the implementation of the original
sem_* / shm_* functions that need to be answered in order to make my
implementations (more) compatible:

  - What is the perm argument of sem_get() and shm_attach() for? Is
    this, too, needed to be emulated?

  - What does shm_attach() return if for some reason the creation or
    opening of a shared memory segment fails? Although it is unlikely
    that this may happen with nmy fake shared memory implementation, as
    the variables are held in a SQL table instead of RAM.

  - Is it true that shm_detach() only removes the shm_identifier for a
    shared memory segment from some sort of list but doesn't remove the
    stored variables of that segement?

  - How do the functions shm_get_var() and shm_remove_var() behave if
    the given shared memory segment and / or variable doesn't exist?

  - How do the functions shm_detach() and shm_remove() behave if
    the given shared memory segment doesn't exist?

  - How do the functions sem_acquire() and sem_release() behave if the
    given semaphore doesn't exist?

-- 
 Homepage : http://gravedancer.rc5.de \ eMail: [email protected]

 PHP-Stand auf Europas größter Linux-Messe: 'Linux-Tag' !
 weitere Infos @ http://www.dynamic-webpages.de/