The User Library (contd.)



Data Structures:
localLockArr : The array containing the locks.


Various functions provided to user programs are listed below:

int RegisterProgram( int pid)
    This function is called by the function ArcStartUp() which in turn is called by the user program during its initialization. It receives as argument the process-id, pid, of the invoking process. This function call a RPC function register_program_svc(int pid) on the local coordinator and sends this pid as an argument. The coordinator then stores this pid in its list of pids.

int UnRegisterProgram( int pid)
    This function is for deregistering a user process from the coordinator when it has finished its execution. The function takes as argument the pid of the process that is to be deregistered. It then calls a RPC function unregister_program(int pid) on the local coordinator which removes this pid from its list of pids.

LocalLockArr* AcquireLocks( int locksRequired)
    When the user program wants to perform computation, it needs to obtain locks depending on the task size. The user program calls GetLocks(int num) function present in the file arcGlob.c. The argument in this function is the number of locks that the user wants to acquire. From within the function GetLocks(int num), call to the function AcquireLocks(int locksRequired) is made.
    This function call the RPC service get_locks_available_svc(locksRequired) on the local coordinator and receives an array of locks. This is stored in the array localLockArr and it is then returned by this function.

MagicNumber* CalculateMagicNum()
    The function makes a RPC call calculate_cur_magicnum_ver2_svc() on the local coordinator to obtain the magic number. The magic number that is returned by the RPC call is returned by this function.