File indexing completed on 2026-01-02 10:13:36
0001 #ifndef ___XRD_SCHED_H___
0002 #define ___XRD_SCHED_H___
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #include <unistd.h>
0033 #include <sys/types.h>
0034
0035 #include "XrdSys/XrdSysPthread.hh"
0036 #include "Xrd/XrdJob.hh"
0037
0038 class XrdOucTrace;
0039 class XrdSchedulerPID;
0040 class XrdSysError;
0041 class XrdSysTrace;
0042
0043 #define MAX_SCHED_PROCS 30000
0044 #define DFL_SCHED_PROCS 8192
0045
0046 class XrdScheduler : public XrdJob
0047 {
0048 public:
0049
0050 int Active() {return num_Workers - idl_Workers + num_JobsinQ;}
0051
0052 void Cancel(XrdJob *jp);
0053
0054 inline int canStick() {return num_Workers < stk_Workers
0055 || (num_Workers-idl_Workers) < stk_Workers;}
0056
0057 void DoIt();
0058
0059 pid_t Fork(const char *id);
0060
0061 void *Reaper();
0062
0063 void Run();
0064
0065 void Schedule(XrdJob *jp);
0066 void Schedule(int num, XrdJob *jfirst, XrdJob *jlast);
0067 void Schedule(XrdJob *jp, time_t atime);
0068
0069 void setParms(int minw, int maxw, int avlt, int maxi, int once=0);
0070
0071 void Start();
0072
0073 int Stats(char *buff, int blen, int do_sync=0);
0074
0075 void TimeSched();
0076
0077 void setNproc(const bool limlower);
0078
0079
0080
0081 int num_TCreate;
0082 int num_TDestroy;
0083 int num_Jobs;
0084 int max_QLength;
0085 int num_Limited;
0086
0087
0088
0089 XrdScheduler(XrdSysError *eP, XrdSysTrace *tP,
0090 int minw=8, int maxw=8192, int maxi=780);
0091
0092
0093
0094
0095
0096 XrdScheduler(XrdSysError *eP, XrdOucTrace *tP,
0097 int minw=8, int maxw=8192, int maxi=780);
0098
0099
0100
0101 XrdScheduler(int minw=3, int maxw=128, int maxi=12);
0102
0103 ~XrdScheduler();
0104
0105 private:
0106 XrdSysError *XrdLog;
0107 XrdSysTrace *XrdTrace;
0108 XrdOucTrace *XrdTraceOld;
0109
0110 XrdSysMutex DispatchMutex;
0111 int idl_Workers;
0112
0113 int min_Workers;
0114 int max_Workers;
0115 int max_Workidl;
0116 int num_Workers;
0117 int stk_Workers;
0118 int num_JobsinQ;
0119 int num_Layoffs;
0120
0121 XrdJob *WorkFirst;
0122 XrdJob *WorkLast;
0123 XrdSysSemaphore WorkAvail;
0124 XrdSysMutex SchedMutex;
0125
0126 XrdJob *TimerQueue;
0127 XrdSysCondVar TimerRings;
0128 XrdSysMutex TimerMutex;
0129
0130 XrdSchedulerPID *firstPID;
0131 XrdSysMutex ReaperMutex;
0132
0133 void Boot(XrdSysError *eP, XrdSysTrace *tP, int minw, int maxw, int maxi);
0134 void hireWorker(int dotrace=1);
0135 void Init(int minw, int maxw, int maxi);
0136 void Monitor();
0137 void traceExit(pid_t pid, int status);
0138 static const char *TraceID;
0139 };
0140 #endif