Article Listing 1 Listing 2 Listing 3 Listing 4
Listing 5 Listing 6 Listing 7 Listing 8 Listing 9
Listing 10 Listing 11 Listing 12 Listing 13 Sidebar aug2004.tar

Listing 2 Init_semaphore()

{
    # Init_semaphore sets the number of resources for a semaphore.

    local FUNC_NAME=Init_semaphore
    ${TRACE:-trace $FUNC_NAME $@}

    local semaphore=$1
    integer num_resources=$2

    if ! is_initialized $semaphore
    then
        if ! create_directories $semaphore
        then
            return 1
        fi
    fi
    ${INFO:-info "Initializing semaphore $semaphore to $num_resources..."}
    set_num_resources $semaphore $num_resources
    return $?
}