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 7 set_num_resources()

{
    # Sets the number of resources for the semaphore. Returns 0 if the
    # number of resources was set; otherwise, returns non-zero.

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

    local semaphore=$1
    integer num_resources=$2
    local resources_file=$HOME_DIR/$semaphore/$RESOURCES_FILENAME

    if is_non_negative_integer $num_resources
    then
        echo $num_resources > $resources_file
        return $?
    else
        return 1
    fi
}