dm_sem Module

Named and unnamed POSIX semaphores. Has to be linked with -lpthread.


Uses

  • module~~dm_sem~~UsesGraph module~dm_sem dm_sem module~dm_error dm_error module~dm_sem->module~dm_error module~dm_id dm_id module~dm_sem->module~dm_id unix unix module~dm_sem->unix module~dm_ascii dm_ascii module~dm_error->module~dm_ascii module~dm_kind dm_kind module~dm_error->module~dm_kind iso_fortran_env iso_fortran_env module~dm_kind->iso_fortran_env

Used by

  • module~~dm_sem~~UsedByGraph module~dm_sem dm_sem module~dmpack dmpack module~dmpack->module~dm_sem

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: SEM_MODE = int(o'0660')

Permissions.

integer, public, parameter :: SEM_NAME_LEN = ID_LEN+1

Max. semaphore identifier length.


Interfaces

public interface dm_sem_post

Post to named or unnamed sempahore.

  • private function sem_post_named(sem) result(rc)

    Increases semaphore value. Returns E_SYSTEM on error.

    Arguments

    Type IntentOptional Attributes Name
    type(sem_named_type), intent(inout) :: sem

    Semaphore type.

    Return Value integer

  • private function sem_post_unnamed(sem) result(rc)

    Increases semaphore value. Returns E_SYSTEM on error.

    Arguments

    Type IntentOptional Attributes Name
    type(sem_unnamed_type), intent(inout), target :: sem

    Semaphore type.

    Return Value integer

public interface dm_sem_value

Get value of named or unnamed sempahore.

  • private function sem_value_named(sem, value) result(rc)

    Returns the current semaphore value. Returns E_SYSTEM on error.

    Arguments

    Type IntentOptional Attributes Name
    type(sem_named_type), intent(inout) :: sem

    Semaphore type.

    integer, intent(out) :: value

    Returned value.

    Return Value integer

  • private function sem_value_unnamed(sem, value) result(rc)

    Returns the current semaphore value. Returns E_SYSTEM on error.

    Arguments

    Type IntentOptional Attributes Name
    type(sem_unnamed_type), intent(inout), target :: sem

    Semaphore type.

    integer, intent(out) :: value

    Returned value.

    Return Value integer

public interface dm_sem_wait

Wait for named or unnamed sempahore.

  • private function sem_wait_named(sem) result(rc)

    Waits for semaphore. Returns E_SYSTEM on error.

    Arguments

    Type IntentOptional Attributes Name
    type(sem_named_type), intent(inout) :: sem

    Semaphore type.

    Return Value integer

  • private function sem_wait_unnamed(sem) result(rc)

    Waits for semaphore. Returns E_SYSTEM on error.

    Arguments

    Type IntentOptional Attributes Name
    type(sem_unnamed_type), intent(inout), target :: sem

    Semaphore type.

    Return Value integer


Derived Types

type, public ::  sem_named_type

Named semaphore type.

type, public ::  sem_unnamed_type

Unnamed semaphore type.


Functions

public function dm_sem_close(sem) result(rc)

Closes named semaphore. The function returns the following error codes:

Read more…

Arguments

Type IntentOptional Attributes Name
type(sem_named_type), intent(inout) :: sem

Semaphore type.

Return Value integer

public function dm_sem_destroy(sem) result(rc)

Destroys unnamed semaphore. The function returns the following error codes:

Read more…

Arguments

Type IntentOptional Attributes Name
type(sem_unnamed_type), intent(inout) :: sem

Semaphore type.

Return Value integer

public function dm_sem_init(sem, value) result(rc)

Initialises unnamed semaphore. The function returns the following error codes:

Read more…

Arguments

Type IntentOptional Attributes Name
type(sem_unnamed_type), intent(inout) :: sem

Semaphore type.

integer, intent(in), optional :: value

Initial value.

Return Value integer

public function dm_sem_open(sem, name, value, create, mode) result(rc)

Opens and optionally creates named semaphore. The given name shall not start with a leading /.

Read more…

Arguments

Type IntentOptional Attributes Name
type(sem_named_type), intent(inout) :: sem

Semaphore type.

character(len=*), intent(in) :: name

Semaphore name (without leading /).

integer, intent(in), optional :: value

Initial value.

logical, intent(in), optional :: create

Create semaphore.

integer, intent(in), optional :: mode

Permissions.

Return Value integer

public function dm_sem_name(sem) result(name)

Returns the name of the semaphore.

Arguments

Type IntentOptional Attributes Name
type(sem_named_type), intent(inout) :: sem

Semaphore type.

Return Value character(len=:), allocatable

Semaphore name.

public function dm_sem_unlink(sem) result(rc)

Unlinks named semaphore. Returns E_SYSTEM on error.

Arguments

Type IntentOptional Attributes Name
type(sem_named_type), intent(inout) :: sem

Semaphore type.

Return Value integer