int pbs_rescrelease( int c, resource_t rh) { struct batch_reply *reply; int rc; int local_errno = 0; pthread_mutex_lock(connection[c].ch_mutex); if ((rc = PBS_resc(c, PBS_BATCH_ReleaseResc, (char **)0, 0, rh)) != 0) { pthread_mutex_unlock(connection[c].ch_mutex); return (rc); } /* now get reply */ reply = PBSD_rdrpy(&local_errno, c); PBSD_FreeReply(reply); rc = connection[c].ch_errno; pthread_mutex_unlock(connection[c].ch_mutex); return(rc); }
int pbs_rescquery( int c, char **resclist, /* In - list of queries */ int num_resc, /* In - number in list */ int *available, /* Out - number available per query */ int *allocated, /* Out - number allocated per query */ int *reserved, /* Out - number reserved per query */ int *down) /* Out - number down/off per query */ { int i; struct batch_reply *reply; int rc = 0; int local_errno = 0; pthread_mutex_lock(connection[c].ch_mutex); if (resclist == NULL) { connection[c].ch_errno = PBSE_RMNOPARAM; pthread_mutex_unlock(connection[c].ch_mutex); return(PBSE_RMNOPARAM); } /* send request */ if ((rc = PBS_resc(c, PBS_BATCH_Rescq, resclist, num_resc, (resource_t)0)) != 0) { pthread_mutex_unlock(connection[c].ch_mutex); return(rc); } /* read in reply */ reply = PBSD_rdrpy(&local_errno, c); if (((rc = connection[c].ch_errno) == PBSE_NONE)) { /* copy in available and allocated numbers */ for (i = 0;i < num_resc;++i) { *(available + i) = *(reply->brp_un.brp_rescq.brq_avail + i); *(allocated + i) = *(reply->brp_un.brp_rescq.brq_alloc + i); *(reserved + i) = *(reply->brp_un.brp_rescq.brq_resvd + i); *(down + i) = *(reply->brp_un.brp_rescq.brq_down + i); } } PBSD_FreeReply(reply); pthread_mutex_unlock(connection[c].ch_mutex); return(rc); } /* END pbs_rescquery() */
int pbs_rescrelease(int c, pbs_resource_t rh) { struct batch_reply *reply; int rc; /* initialize the thread context data, if not already initialized */ if (pbs_client_thread_init_thread_context() != 0) return pbs_errno; /* lock pthread mutex here for this connection */ /* blocking call, waits for mutex release */ if (pbs_client_thread_lock_connection(c) != 0) return pbs_errno; if ((rc = PBS_resc(c, PBS_BATCH_ReleaseResc, (char **)0, 0, rh)) != 0) { (void)pbs_client_thread_unlock_connection(c); return (rc); } /* now get reply */ reply = PBSD_rdrpy(c); PBSD_FreeReply(reply); rc = connection[c].ch_errno; /* unlock the thread lock and update the thread context data */ if (pbs_client_thread_unlock_connection(c) != 0) return pbs_errno; return (rc); }
int pbs_rescreserve(int c, char **rl, int num_resc, pbs_resource_t *prh) { int rc; struct batch_reply *reply; /* initialize the thread context data, if not already initialized */ if (pbs_client_thread_init_thread_context() != 0) return pbs_errno; /* lock pthread mutex here for this connection */ /* blocking call, waits for mutex release */ if (pbs_client_thread_lock_connection(c) != 0) return pbs_errno; if (rl == NULL) { pbs_errno = connection[c].ch_errno = PBSE_RMNOPARAM; (void)pbs_client_thread_unlock_connection(c); return pbs_errno; } if (prh == NULL) { pbs_errno = connection[c].ch_errno = PBSE_RMBADPARAM; (void)pbs_client_thread_unlock_connection(c); return pbs_errno; } /* send request */ if ((rc = PBS_resc(c, PBS_BATCH_ReserveResc, rl, num_resc, *prh)) != 0) { (void)pbs_client_thread_unlock_connection(c); return (rc); } /* * now get reply, if reservation successful, the reservation handle, * pbs_resource_t, is in the aux field */ reply = PBSD_rdrpy(c); if (((rc = connection[c].ch_errno) == PBSE_NONE) || (rc == PBSE_RMPART)) { *prh = reply->brp_auxcode; } PBSD_FreeReply(reply); /* unlock the thread lock and update the thread context data */ if (pbs_client_thread_unlock_connection(c) != 0) return pbs_errno; return (rc); }
int pbs_rescreserve( int c, /* connection */ char **rl, /* list of resources */ int num_resc, /* number of items in list */ resource_t *prh) /* ptr to resource reservation handle */ { int rc; int local_errno = 0; struct batch_reply *reply; pthread_mutex_lock(connection[c].ch_mutex); if (rl == NULL) { connection[c].ch_errno = PBSE_RMNOPARAM; pthread_mutex_unlock(connection[c].ch_mutex); return (PBSE_RMNOPARAM); } if (prh == NULL) { connection[c].ch_errno = PBSE_RMBADPARAM; pthread_mutex_unlock(connection[c].ch_mutex); return (PBSE_RMBADPARAM); } /* send request */ if ((rc = PBS_resc(c, PBS_BATCH_ReserveResc, rl, num_resc, *prh)) != 0) { pthread_mutex_unlock(connection[c].ch_mutex); return (rc); } /* * now get reply, if reservation successful, the reservation handle, * resource_t, is in the aux field */ reply = PBSD_rdrpy(&local_errno, c); if (((rc = connection[c].ch_errno) == PBSE_NONE) || (rc == PBSE_RMPART)) { *prh = reply->brp_auxcode; } PBSD_FreeReply(reply); pthread_mutex_unlock(connection[c].ch_mutex); return (rc); } /* END pbs_rescreserve() */
int pbs_rescquery(int c, char **resclist, int num_resc, int *available, int *allocated, int *reserved, int *down) { int i; struct batch_reply *reply; int rc = 0; /* initialize the thread context data, if not already initialized */ if (pbs_client_thread_init_thread_context() != 0) return pbs_errno; /* lock pthread mutex here for this connection */ /* blocking call, waits for mutex release */ if (pbs_client_thread_lock_connection(c) != 0) return pbs_errno; if (resclist == 0) { pbs_errno = connection[c].ch_errno = PBSE_RMNOPARAM; (void)pbs_client_thread_unlock_connection(c); return pbs_errno; } /* send request */ if ((rc = PBS_resc(c, PBS_BATCH_Rescq, resclist, num_resc, (pbs_resource_t)0)) != 0) { (void)pbs_client_thread_unlock_connection(c); return rc; } /* read in reply */ reply = PBSD_rdrpy(c); if ((rc = connection[c].ch_errno) == PBSE_NONE && reply->brp_choice == BATCH_REPLY_CHOICE_RescQuery) { struct brp_rescq *resq = &reply->brp_un.brp_rescq; if (resq == NULL || num_resc != resq->brq_number) { rc = pbs_errno = connection[c].ch_errno = PBSE_IRESVE; goto done; } /* copy in available and allocated numbers */ for (i=0; i<num_resc; i++) { available[i] = resq->brq_avail[i]; allocated[i] = resq->brq_alloc[i]; reserved[i] = resq->brq_resvd[i]; down[i] = resq->brq_down[i]; } } done: PBSD_FreeReply(reply); /* unlock the thread lock and update the thread context data */ if (pbs_client_thread_unlock_connection(c) != 0) return pbs_errno; return (rc); }