xrootd
Loading...
Searching...
No Matches
XrdScheduler.hh
Go to the documentation of this file.
1#ifndef ___XRD_SCHED_H___
2#define ___XRD_SCHED_H___
3/******************************************************************************/
4/* */
5/* X r d S c h e d u l e r . h h */
6/* */
7/* (c) 2004 by the Board of Trustees of the Leland Stanford, Jr., University */
8/* Produced by Andrew Hanushevsky for Stanford University under contract */
9/* DE-AC02-76-SFO0515 with the Department of Energy */
10/* */
11/* This file is part of the XRootD software suite. */
12/* */
13/* XRootD is free software: you can redistribute it and/or modify it under */
14/* the terms of the GNU Lesser General Public License as published by the */
15/* Free Software Foundation, either version 3 of the License, or (at your */
16/* option) any later version. */
17/* */
18/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
19/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
20/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
21/* License for more details. */
22/* */
23/* You should have received a copy of the GNU Lesser General Public License */
24/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
25/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
26/* */
27/* The copyright holder's institutional names and contributor's names may not */
28/* be used to endorse or promote products derived from this software without */
29/* specific prior written permission of the institution or contributor. */
30/******************************************************************************/
31
32#include <unistd.h>
33#include <sys/types.h>
34
36#include "Xrd/XrdJob.hh"
37
38class XrdOucTrace;
39class XrdSchedulerPID;
40class XrdSysError;
41class XrdSysTrace;
42
43#define MAX_SCHED_PROCS 30000
44
45class XrdScheduler : public XrdJob
46{
47public:
48
50
51void Cancel(XrdJob *jp);
52
55
56void DoIt();
57
58pid_t Fork(const char *id);
59
60void *Reaper();
61
62void Run();
63
64void Schedule(XrdJob *jp);
65void Schedule(int num, XrdJob *jfirst, XrdJob *jlast);
66void Schedule(XrdJob *jp, time_t atime);
67
68void setParms(int minw, int maxw, int avlt, int maxi, int once=0);
69
70void Start();
71
72int Stats(char *buff, int blen, int do_sync=0);
73
74void TimeSched();
75
76// Statistical information
77//
78int num_TCreate; // Number of threads created
79int num_TDestroy;// Number of threads destroyed
80int num_Jobs; // Number of jobs scheduled
81int max_QLength; // Longest queue length we had
82int num_Limited; // Number of times max was reached
83
84// This is the preferred constructor
85//
87 int minw=8, int maxw=8192, int maxi=780);
88
89// This constructor is only maintained for ABI compatibility and will be
90// removed in a future major release. While syntactically compatible the
91// sematics now are slightly different and tracing might not occur.
92//
94 int minw=8, int maxw=8192, int maxi=780);
95
96// This constructor is used for a stand-alone scheduler.
97//
98 XrdScheduler(int minw=3, int maxw=128, int maxi=12);
99
101
102private:
105XrdOucTrace *XrdTraceOld; // This is only used for ABI compatibility
106
107XrdSysMutex DispatchMutex; // Disp: Protects above area
108int idl_Workers; // Disp: Number of idle workers
109
110int min_Workers; // Sched: Min threads we need to have
111int max_Workers; // Sched: Max threads we can start
112int max_Workidl; // Sched: Max idle time for threads above min_Workers
113int num_Workers; // Sched: Number of threads we have
114int stk_Workers; // Sched: Number of sticky workers we can have
115int num_JobsinQ; // Sched: Number of outstanding jobs in the queue
116int num_Layoffs; // Sched: Number of threads to terminate
117
118XrdJob *WorkFirst; // Pending work
121XrdSysMutex SchedMutex; // Protects private area
122
123XrdJob *TimerQueue; // Pending work
125XrdSysMutex TimerMutex; // Protects scheduler area
126
127XrdSchedulerPID *firstPID;
129
130void Boot(XrdSysError *eP, XrdSysTrace *tP, int minw, int maxw, int maxi);
131void hireWorker(int dotrace=1);
132void Init(int minw, int maxw, int maxi);
133void Monitor();
134void traceExit(pid_t pid, int status);
135static const char *TraceID;
136};
137#endif
Definition XrdJob.hh:43
Definition XrdOucTrace.hh:36
Definition XrdScheduler.hh:46
int Active()
Definition XrdScheduler.hh:49
int num_Workers
Definition XrdScheduler.hh:113
int max_QLength
Definition XrdScheduler.hh:81
int Stats(char *buff, int blen, int do_sync=0)
XrdSysSemaphore WorkAvail
Definition XrdScheduler.hh:120
int max_Workidl
Definition XrdScheduler.hh:112
int num_Jobs
Definition XrdScheduler.hh:80
int num_TCreate
Definition XrdScheduler.hh:78
void hireWorker(int dotrace=1)
XrdSchedulerPID * firstPID
Definition XrdScheduler.hh:127
void Init(int minw, int maxw, int maxi)
XrdScheduler(XrdSysError *eP, XrdSysTrace *tP, int minw=8, int maxw=8192, int maxi=780)
int min_Workers
Definition XrdScheduler.hh:110
XrdSysMutex DispatchMutex
Definition XrdScheduler.hh:107
void Monitor()
void Boot(XrdSysError *eP, XrdSysTrace *tP, int minw, int maxw, int maxi)
XrdJob * WorkFirst
Definition XrdScheduler.hh:118
void Schedule(XrdJob *jp, time_t atime)
void Schedule(XrdJob *jp)
int idl_Workers
Definition XrdScheduler.hh:108
int canStick()
Definition XrdScheduler.hh:53
XrdScheduler(int minw=3, int maxw=128, int maxi=12)
XrdSysMutex ReaperMutex
Definition XrdScheduler.hh:128
void TimeSched()
XrdScheduler(XrdSysError *eP, XrdOucTrace *tP, int minw=8, int maxw=8192, int maxi=780)
XrdSysError * XrdLog
Definition XrdScheduler.hh:103
int stk_Workers
Definition XrdScheduler.hh:114
XrdSysMutex TimerMutex
Definition XrdScheduler.hh:125
XrdSysTrace * XrdTrace
Definition XrdScheduler.hh:104
void Schedule(int num, XrdJob *jfirst, XrdJob *jlast)
void setParms(int minw, int maxw, int avlt, int maxi, int once=0)
void Cancel(XrdJob *jp)
void traceExit(pid_t pid, int status)
int num_JobsinQ
Definition XrdScheduler.hh:115
int num_Layoffs
Definition XrdScheduler.hh:116
XrdJob * TimerQueue
Definition XrdScheduler.hh:123
void * Reaper()
XrdOucTrace * XrdTraceOld
Definition XrdScheduler.hh:105
XrdSysCondVar TimerRings
Definition XrdScheduler.hh:124
int max_Workers
Definition XrdScheduler.hh:111
XrdSysMutex SchedMutex
Definition XrdScheduler.hh:121
int num_Limited
Definition XrdScheduler.hh:82
int num_TDestroy
Definition XrdScheduler.hh:79
static const char * TraceID
Definition XrdScheduler.hh:135
pid_t Fork(const char *id)
XrdJob * WorkLast
Definition XrdScheduler.hh:119
Definition XrdSysPthread.hh:79
Definition XrdSysError.hh:90
Definition XrdSysPthread.hh:165
Definition XrdSysPthread.hh:494
Definition XrdSysTrace.hh:49