|
||||
File indexing completed on 2025-01-30 10:27:52
0001 #ifndef ___XRD_SCHED_H___ 0002 #define ___XRD_SCHED_H___ 0003 /******************************************************************************/ 0004 /* */ 0005 /* X r d S c h e d u l e r . h h */ 0006 /* */ 0007 /* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */ 0008 /* Produced by Andrew Hanushevsky for Stanford University under contract */ 0009 /* DE-AC02-76-SFO0515 with the Department of Energy */ 0010 /* */ 0011 /* This file is part of the XRootD software suite. */ 0012 /* */ 0013 /* XRootD is free software: you can redistribute it and/or modify it under */ 0014 /* the terms of the GNU Lesser General Public License as published by the */ 0015 /* Free Software Foundation, either version 3 of the License, or (at your */ 0016 /* option) any later version. */ 0017 /* */ 0018 /* XRootD is distributed in the hope that it will be useful, but WITHOUT */ 0019 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */ 0020 /* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */ 0021 /* License for more details. */ 0022 /* */ 0023 /* You should have received a copy of the GNU Lesser General Public License */ 0024 /* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */ 0025 /* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */ 0026 /* */ 0027 /* The copyright holder's institutional names and contributor's names may not */ 0028 /* be used to endorse or promote products derived from this software without */ 0029 /* specific prior written permission of the institution or contributor. */ 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 0045 class XrdScheduler : public XrdJob 0046 { 0047 public: 0048 0049 int Active() {return num_Workers - idl_Workers + num_JobsinQ;} 0050 0051 void Cancel(XrdJob *jp); 0052 0053 inline int canStick() {return num_Workers < stk_Workers 0054 || (num_Workers-idl_Workers) < stk_Workers;} 0055 0056 void DoIt(); 0057 0058 pid_t Fork(const char *id); 0059 0060 void *Reaper(); 0061 0062 void Run(); 0063 0064 void Schedule(XrdJob *jp); 0065 void Schedule(int num, XrdJob *jfirst, XrdJob *jlast); 0066 void Schedule(XrdJob *jp, time_t atime); 0067 0068 void setParms(int minw, int maxw, int avlt, int maxi, int once=0); 0069 0070 void Start(); 0071 0072 int Stats(char *buff, int blen, int do_sync=0); 0073 0074 void TimeSched(); 0075 0076 // Statistical information 0077 // 0078 int num_TCreate; // Number of threads created 0079 int num_TDestroy;// Number of threads destroyed 0080 int num_Jobs; // Number of jobs scheduled 0081 int max_QLength; // Longest queue length we had 0082 int num_Limited; // Number of times max was reached 0083 0084 // This is the preferred constructor 0085 // 0086 XrdScheduler(XrdSysError *eP, XrdSysTrace *tP, 0087 int minw=8, int maxw=8192, int maxi=780); 0088 0089 // This constructor is only maintained for ABI compatibility and will be 0090 // removed in a future major release. While syntactically compatible the 0091 // sematics now are slightly different and tracing might not occur. 0092 // 0093 XrdScheduler(XrdSysError *eP, XrdOucTrace *tP, 0094 int minw=8, int maxw=8192, int maxi=780); 0095 0096 // This constructor is used for a stand-alone scheduler. 0097 // 0098 XrdScheduler(int minw=3, int maxw=128, int maxi=12); 0099 0100 ~XrdScheduler(); 0101 0102 private: 0103 XrdSysError *XrdLog; 0104 XrdSysTrace *XrdTrace; 0105 XrdOucTrace *XrdTraceOld; // This is only used for ABI compatibility 0106 0107 XrdSysMutex DispatchMutex; // Disp: Protects above area 0108 int idl_Workers; // Disp: Number of idle workers 0109 0110 int min_Workers; // Sched: Min threads we need to have 0111 int max_Workers; // Sched: Max threads we can start 0112 int max_Workidl; // Sched: Max idle time for threads above min_Workers 0113 int num_Workers; // Sched: Number of threads we have 0114 int stk_Workers; // Sched: Number of sticky workers we can have 0115 int num_JobsinQ; // Sched: Number of outstanding jobs in the queue 0116 int num_Layoffs; // Sched: Number of threads to terminate 0117 0118 XrdJob *WorkFirst; // Pending work 0119 XrdJob *WorkLast; 0120 XrdSysSemaphore WorkAvail; 0121 XrdSysMutex SchedMutex; // Protects private area 0122 0123 XrdJob *TimerQueue; // Pending work 0124 XrdSysCondVar TimerRings; 0125 XrdSysMutex TimerMutex; // Protects scheduler area 0126 0127 XrdSchedulerPID *firstPID; 0128 XrdSysMutex ReaperMutex; 0129 0130 void Boot(XrdSysError *eP, XrdSysTrace *tP, int minw, int maxw, int maxi); 0131 void hireWorker(int dotrace=1); 0132 void Init(int minw, int maxw, int maxi); 0133 void Monitor(); 0134 void traceExit(pid_t pid, int status); 0135 static const char *TraceID; 0136 }; 0137 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |