XRootD
Loading...
Searching...
No Matches
XrdScheduler Class Reference

#include <XrdScheduler.hh>

+ Inheritance diagram for XrdScheduler:
+ Collaboration diagram for XrdScheduler:

Public Member Functions

 XrdScheduler (int minw=3, int maxw=128, int maxi=12)
 
 XrdScheduler (XrdSysError *eP, XrdOucTrace *tP, int minw=8, int maxw=8192, int maxi=780)
 
 XrdScheduler (XrdSysError *eP, XrdSysTrace *tP, int minw=8, int maxw=8192, int maxi=780)
 
 ~XrdScheduler ()
 
int Active ()
 
void Cancel (XrdJob *jp)
 
int canStick ()
 
void DoIt ()
 
pid_t Fork (const char *id)
 
void * Reaper ()
 
void Run ()
 
void Schedule (int num, XrdJob *jfirst, XrdJob *jlast)
 
void Schedule (XrdJob *jp)
 
void Schedule (XrdJob *jp, time_t atime)
 
void setNproc (const bool limlower)
 
void setParms (int minw, int maxw, int avlt, int maxi, int once=0)
 
void Start ()
 
int Stats (char *buff, int blen, int do_sync=0)
 
void TimeSched ()
 
- Public Member Functions inherited from XrdJob
 XrdJob (const char *desc="")
 
virtual ~XrdJob ()
 

Public Attributes

int max_QLength
 
int num_Jobs
 
int num_Limited
 
int num_TCreate
 
int num_TDestroy
 
- Public Attributes inherited from XrdJob
const char * Comment
 
XrdJobNextJob
 

Detailed Description

Definition at line 46 of file XrdScheduler.hh.

Constructor & Destructor Documentation

◆ XrdScheduler() [1/3]

XrdScheduler::XrdScheduler ( XrdSysError * eP,
XrdSysTrace * tP,
int minw = 8,
int maxw = 8192,
int maxi = 780 )

Definition at line 97 of file XrdScheduler.cc.

99 : XrdJob("underused thread monitor"),
100 XrdTraceOld(0), WorkAvail(0, "sched work")
101{
102 Boot(eP, tP, minw, maxw, maxi);
103}
XrdJob(const char *desc="")
Definition XrdJob.hh:51

◆ XrdScheduler() [2/3]

XrdScheduler::XrdScheduler ( XrdSysError * eP,
XrdOucTrace * tP,
int minw = 8,
int maxw = 8192,
int maxi = 780 )

Definition at line 108 of file XrdScheduler.cc.

110 : XrdJob("underused thread monitor"),
111 XrdTraceOld(tP), WorkAvail(0, "sched work")
112{
113
114// Invoke the main initialization function with a new style trace object
115//
116 Boot(eP, new XrdSysTrace("Xrd", eP->logger()), minw, maxw, maxi);
117}
XrdSysLogger * logger(XrdSysLogger *lp=0)

References XrdSysError::logger().

+ Here is the call graph for this function:

◆ XrdScheduler() [3/3]

XrdScheduler::XrdScheduler ( int minw = 3,
int maxw = 128,
int maxi = 12 )

Definition at line 123 of file XrdScheduler.cc.

124 : XrdJob("underused thread monitor"),
125 XrdTraceOld(0), WorkAvail(0, "sched work")
126{
128 int eFD;
129
130// Get a file descriptor mirroring standard error
131//
132#if ( defined(__linux__) || defined(__GNU__) ) && defined(F_DUPFD_CLOEXEC)
133 eFD = fcntl(STDERR_FILENO, F_DUPFD_CLOEXEC, 0);
134#else
135 eFD = dup(STDERR_FILENO);
136 fcntl(eFD, F_SETFD, FD_CLOEXEC);
137#endif
138
139// Now we need to get a logger object. We make this a real dumb one.
140//
141 Logger = new XrdSysLogger(eFD, 0);
142 XrdLog = new XrdSysError(Logger);
143
144// Now get a trace object
145//
146 XrdTrace = new XrdSysTrace("Xrd", Logger);
147 if (getenv("XRDDEBUG") != 0) XrdTrace->What = TRACE_SCHED;
148
149// Set remaining values. We do no use maximum possible threads here.
150//
151 Init(minw, maxw, maxi);
152}
static XrdSysLogger Logger
int fcntl(int fd, int cmd,...)
#define TRACE_SCHED
Definition XrdTrace.hh:42

References fcntl(), Logger, TRACE_SCHED, and XrdSysTrace::What.

+ Here is the call graph for this function:

◆ ~XrdScheduler()

XrdScheduler::~XrdScheduler ( )

Definition at line 177 of file XrdScheduler.cc.

178{
179}

Member Function Documentation

◆ Active()

int XrdScheduler::Active ( )
inline

Definition at line 50 of file XrdScheduler.hh.

50{return num_Workers - idl_Workers + num_JobsinQ;}

Referenced by XrdStats::Report().

+ Here is the caller graph for this function:

◆ Cancel()

void XrdScheduler::Cancel ( XrdJob * jp)

Definition at line 185 of file XrdScheduler.cc.

186{
187 XrdJob *p, *pp = 0;
188
189// Lock the queue
190//
191 TimerMutex.Lock();
192
193// Find the matching job, if any
194//
195 p = TimerQueue;
196 while(p && p != jp) {pp = p; p = p->NextJob;}
197
198// Delete the job element
199//
200 if (p)
201 {if (pp) pp->NextJob = p->NextJob;
202 else TimerQueue = p->NextJob;
203 TRACE(SCHED, "time event " <<jp->Comment <<" cancelled");
204 }
205
206// All done
207//
208 TimerMutex.UnLock();
209}
#define TRACE(act, x)
Definition XrdTrace.hh:63
XrdJob * NextJob
Definition XrdJob.hh:46
const char * Comment
Definition XrdJob.hh:47

References XrdJob::Comment, XrdSysMutex::Lock(), XrdJob::NextJob, TRACE, and XrdSysMutex::UnLock().

Referenced by XrdXrootdJob::~XrdXrootdJob(), XrdXrootdTransit::Recycle(), Schedule(), and setParms().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ canStick()

int XrdScheduler::canStick ( )
inline

Definition at line 54 of file XrdScheduler.hh.

54 {return num_Workers < stk_Workers
55 || (num_Workers-idl_Workers) < stk_Workers;}

Referenced by XrdLinkXeq::DoIt().

+ Here is the caller graph for this function:

◆ DoIt()

void XrdScheduler::DoIt ( )
virtual

Implements XrdJob.

Definition at line 215 of file XrdScheduler.cc.

216{
217 int num_kill, num_idle;
218
219// Now check if there are too many idle threads (kill them if there are)
220//
221 if (!num_JobsinQ)
222 {DispatchMutex.Lock(); num_idle = idl_Workers; DispatchMutex.UnLock();
223 num_kill = num_idle - min_Workers;
224 TRACE(SCHED, num_Workers <<" threads; " <<num_idle <<" idle");
225 if (num_kill > 0)
226 {if (num_kill > 1) num_kill = num_kill/2;
227 SchedMutex.Lock();
228 num_Layoffs = num_kill;
229 while(num_kill--) WorkAvail.Post();
230 SchedMutex.UnLock();
231 }
232 }
233
234// Check if we should reschedule ourselves
235//
236 if (max_Workidl > 0) Schedule((XrdJob *)this, max_Workidl+time(0));
237}
void Schedule(XrdJob *jp)

References XrdSysMutex::Lock(), XrdSysSemaphore::Post(), Schedule(), TRACE, and XrdSysMutex::UnLock().

+ Here is the call graph for this function:

◆ Fork()

pid_t XrdScheduler::Fork ( const char * id)

Definition at line 245 of file XrdScheduler.cc.

246{
247 static int retc, ReaperStarted = 0;
248 pthread_t tid;
249 pid_t pid;
250
251// Fork
252//
253 if ((pid = fork()) < 0)
254 {XrdLog->Emsg("Scheduler",errno,"fork to handle",id);
255 return pid;
256 }
257 if (!pid) return pid;
258
259// Obtain the status of the reaper thread.
260//
261 ReaperMutex.Lock();
262 firstPID = new XrdSchedulerPID(pid, firstPID);
263 retc = ReaperStarted;
264 ReaperStarted = 1;
265 ReaperMutex.UnLock();
266
267// Start the reaper thread if it has not started.
268//
269 if (!retc)
270 if ((retc = XrdSysThread::Run(&tid, XrdStartReaper, (void *)this,
271 0, "Process reaper")))
272 {XrdLog->Emsg("Scheduler", retc, "create reaper thread");
273 ReaperStarted = 0;
274 }
275
276 return pid;
277}
void * XrdStartReaper(void *carg)
int Emsg(const char *esfx, int ecode, const char *text1, const char *text2=0)
static int Run(pthread_t *, void *(*proc)(void *), void *arg, int opts=0, const char *desc=0)

References XrdSysError::Emsg(), XrdSysMutex::Lock(), XrdSysThread::Run(), XrdSysMutex::UnLock(), and XrdStartReaper().

+ Here is the call graph for this function:

◆ Reaper()

void * XrdScheduler::Reaper ( )

Definition at line 283 of file XrdScheduler.cc.

284{
285 int status;
286 pid_t pid;
287 XrdSchedulerPID *tp, *ptp, *xtp;
288#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_5)
289 struct timespec ts = { 1, 0 };
290#else
291 sigset_t Sset;
292 int signum;
293
294// Set up for signal handling. Note: main() must block this signal at start)
295//
296 sigemptyset(&Sset);
297 sigaddset(&Sset, SIGCHLD);
298#endif
299
300// Wait for all outstanding children
301//
302 do {ReaperMutex.Lock();
303 tp = firstPID; ptp = 0;
304 while(tp)
305 {do {pid = waitpid(tp->pid, &status, WNOHANG);}
306 while (pid < 0 && errno == EINTR);
307 if (pid > 0)
308 {if (TRACING(TRACE_SCHED)) traceExit(pid, status);
309 xtp = tp; tp = tp->next;
310 if (ptp) ptp->next = tp;
311 else firstPID = tp;
312 delete xtp;
313 } else {ptp = tp; tp = tp->next;}
314 }
315 ReaperMutex.UnLock();
316#if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_5)
317 // Mac OS X sigwait() is broken on <= 10.4.
318 } while (nanosleep(&ts, 0) <= 0);
319#else
320 } while(sigwait(&Sset, &signum) >= 0);
321#endif
322 return (void *)0;
323}
static std::string ts()
timestamp output for logging messages
Definition XrdCephOss.cc:53
#define TRACING(x)
Definition XrdTrace.hh:70
XrdSchedulerPID * next

References XrdSysMutex::Lock(), XrdSchedulerPID::next, XrdSchedulerPID::pid, TRACE_SCHED, TRACING, ts(), and XrdSysMutex::UnLock().

Referenced by XrdStartReaper().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Run()

void XrdScheduler::Run ( )

Definition at line 329 of file XrdScheduler.cc.

330{
331 int waiting;
332 XrdJob *jp;
333
334// Wait for work then do it (an endless task for a worker thread)
335//
336 do {do {DispatchMutex.Lock(); idl_Workers++;DispatchMutex.UnLock();
337 WorkAvail.Wait();
338 DispatchMutex.Lock();waiting = --idl_Workers;DispatchMutex.UnLock();
339 SchedMutex.Lock();
340 if ((jp = WorkFirst))
341 {if (!(WorkFirst = jp->NextJob)) WorkLast = 0;
342 if (num_JobsinQ) num_JobsinQ--;
343 else XrdLog->Emsg("Scheduler","Job queue count underflow!");
344 } else {
345 num_JobsinQ = 0;
346 if (num_Layoffs > 0)
347 {num_Layoffs--;
348 if (waiting)
349 {num_TDestroy++; num_Workers--;
350 TRACE(SCHED, "terminating thread; workers=" <<num_Workers);
351 SchedMutex.UnLock();
352 return;
353 }
354 }
355 }
356 SchedMutex.UnLock();
357 } while(!jp);
358
359 // Check if we should hire a new worker (we always want 1 idle thread)
360 // before running this job.
361 //
362 if (!waiting) hireWorker();
363 if (TRACING(TRACE_SCHED) && *(jp->Comment) != '.')
364 {TRACE(SCHED, "running " <<jp->Comment <<" inq=" <<num_JobsinQ);}
365 jp->DoIt();
366 } while(1);
367}
virtual void DoIt()=0

References XrdJob::Comment, XrdJob::DoIt(), XrdSysError::Emsg(), XrdSysMutex::Lock(), XrdJob::NextJob, num_TDestroy, TRACE, TRACE_SCHED, TRACING, XrdSysMutex::UnLock(), XrdSysSemaphore::Wait(), and XrdLog.

Referenced by XrdStartWorking().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Schedule() [1/3]

void XrdScheduler::Schedule ( int num,
XrdJob * jfirst,
XrdJob * jlast )

Definition at line 404 of file XrdScheduler.cc.

405{
406
407// Lock down our data area
408//
409 SchedMutex.Lock();
410
411// Place the request list on the queue
412//
413 jlast->NextJob = 0;
414 if (WorkFirst)
415 {WorkLast->NextJob = jfirst;
416 WorkLast = jlast;
417 } else {
418 WorkFirst = jfirst;
419 WorkLast = jlast;
420 }
421
422// Calculate statistics
423//
424 num_Jobs += numjobs;
425 num_JobsinQ += numjobs;
426 if (num_JobsinQ > max_QLength) max_QLength = num_JobsinQ;
427
428// Indicate number of jobs to work on
429//
430 while(numjobs--) WorkAvail.Post();
431
432// Unlock the data area and return
433//
434 SchedMutex.UnLock();
435}

References XrdSysMutex::Lock(), max_QLength, XrdJob::NextJob, num_Jobs, XrdSysSemaphore::Post(), and XrdSysMutex::UnLock().

+ Here is the call graph for this function:

◆ Schedule() [2/3]

void XrdScheduler::Schedule ( XrdJob * jp)

Definition at line 373 of file XrdScheduler.cc.

374{
375// Lock down our data area
376//
377 SchedMutex.Lock();
378
379// Place the request on the queue and broadcast it
380//
381 jp->NextJob = 0;
382 if (WorkFirst)
383 {WorkLast->NextJob = jp;
384 WorkLast = jp;
385 } else {
386 WorkFirst = jp;
387 WorkLast = jp;
388 }
389 WorkAvail.Post();
390
391// Calculate statistics
392//
393 num_Jobs++;
394 num_JobsinQ++;
395 if (num_JobsinQ > max_QLength) max_QLength = num_JobsinQ;
396
397// Unlock the data area and return
398//
399 SchedMutex.UnLock();
400}

References XrdSysMutex::Lock(), max_QLength, XrdJob::NextJob, num_Jobs, XrdSysSemaphore::Post(), and XrdSysMutex::UnLock().

Referenced by XrdCmsDelNode::XrdCmsDelNode(), XrdCmsDrop::XrdCmsDrop(), XrdCmsDrop::XrdCmsDrop(), XrdStatsJob::XrdStatsJob(), XrdXrootdJob::XrdXrootdJob(), XrdXrootdPrepare::XrdXrootdPrepare(), XrdSsiFileReq::Activate(), XrdSsiEvent::AddEvent(), XrdXrootdAioTask::Completed(), XrdCmsConfig::Configure2(), XrdPfc::IO::Detach(), XrdPollE::Disable(), XrdPollPoll::Disable(), XrdCmsNode::do_SelPrep(), XrdCms::PingClock::DoIt(), XrdCmsBlackList::DoIt(), XrdCmsJob::DoIt(), XrdCmsPrepare::DoIt(), XrdObjectQ< T >::DoIt(), DoIt(), XrdStatsJob::DoIt(), XrdXrootdJob::DoIt(), XrdXrootdMonFile::DoIt(), XrdXrootdMonitor_Ident::DoIt(), XrdXrootdMonitor_Tick::DoIt(), XrdXrootdPrepare::DoIt(), XrdXrootdCallBack::Done(), XrdPosixFileRH::HandleResponse(), XrdCmsBlackList::Init(), XrdXrootdMonFile::Init(), XrdXrootdMonitor::Init(), mainAccept(), mainAdmin(), XrdPfc::ResourceMonitor::perform_purge_check(), XrdPfc::Cache::Prepare(), XrdCmsPrepare::Reset(), XrdSsiUtils::RetErr(), XrdOfsPrepGPIReal::PrepGRun::Sched(), XrdPosixFileRH::Sched(), XrdSsiTaskReal::SchedError(), XrdOssCsiFileAio::SchedReadJob(), XrdOssCsiFileAio::SchedReadJob2(), XrdXrootdAioFob::Schedule(), XrdXrootdAioFob::Schedule(), XrdXrootdJob::Schedule(), XrdOssCsiFileAio::SchedWriteJob(), XrdOssCsiFileAio::SchedWriteJob2(), XrdObjectQ< T >::Set(), setParms(), XrdLinkCtl::Setup(), XrdPollE::Start(), XrdPollPoll::Start(), Start(), XrdSendQ::Terminate(), XrdCmsCache::TickTock(), TimeSched(), and XrdSsiSessReal::UnHold().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Schedule() [3/3]

void XrdScheduler::Schedule ( XrdJob * jp,
time_t atime )

Definition at line 439 of file XrdScheduler.cc.

440{
441 XrdJob *pp = 0, *p;
442
443// Cancel this event, if scheduled
444//
445 Cancel(jp);
446
447// Lock the queue
448//
449 if (TRACING(TRACE_SCHED) && *(jp->Comment) != '.')
450 {TRACE(SCHED, "scheduling " <<jp->Comment <<" in " <<atime-time(0) <<" seconds");}
451 jp->SchedTime = atime;
452 TimerMutex.Lock();
453
454// Find the insertion point for the work element
455//
456 p = TimerQueue;
457 while(p && p->SchedTime <= atime) {pp = p; p = p->NextJob;}
458
459// Insert the job element
460//
461 jp->NextJob = p;
462 if (pp) pp->NextJob = jp;
463 else {TimerQueue = jp; TimerRings.Signal();}
464
465// All done
466//
467 TimerMutex.UnLock();
468}
void Cancel(XrdJob *jp)

References Cancel(), XrdJob::Comment, XrdSysMutex::Lock(), XrdJob::NextJob, XrdSysCondVar::Signal(), TRACE, TRACE_SCHED, TRACING, and XrdSysMutex::UnLock().

+ Here is the call graph for this function:

◆ setNproc()

void XrdScheduler::setNproc ( const bool limlower)

Definition at line 474 of file XrdScheduler.cc.

475{
476 // If supported change the NPROC resource limit and set max_Workers.
477 // Caller can select leaving or increasing the limit, or potentially
478 // setting a more restrictive limit than the current one.
479
480 // If this method is called the setParms method should be called after, so
481 // that a caller supplied value of max_Workers can override the value here.
482
483 // We attempt to set the limit to our maximum supported threads in the
484 // XrdScheduler (with a margin for pid_max).
485
486// Reset the soft limit applied to our process concerning the system wide
487// number threads for our uid (Linux only).
488//
489#if ( defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__)) ) && defined(RLIMIT_NPROC)
490
491 struct rlimit rlim;
492
493// First determine the absolute maximum we can have
494//
495 rlim_t theMax = MAX_SCHED_PROCS;
496 int pdFD, rdsz;
497 if ((pdFD = open("/proc/sys/kernel/pid_max", O_RDONLY)) >= 0)
498 {char pmBuff[32];
499 if ((rdsz = read(pdFD, pmBuff, sizeof(pmBuff))) > 0)
500 {rdsz = atoi(pmBuff);
501 if (rdsz < 16384) theMax = 16384; // This is unlikely
502 else if (rdsz < MAX_SCHED_PROCS)
503 theMax = static_cast<rlim_t>(rdsz-2000);
504 }
505 close(pdFD);
506 }
507
508// We allow disabling the NPROC setting entirely.
509//
510 const bool setnp = (getenv("XRDLEAVENPROC") == 0);
511
512// Get the resource thread limit and set to maximum. In Linux this may be -1
513// to indicate useless infnity, so we have to come up with a number, sigh.
514//
515 if (setnp && !getrlimit(RLIMIT_NPROC, &rlim))
516 {if (rlim.rlim_max == RLIM_INFINITY || rlim.rlim_max > theMax)
517 {if (limlower || (rlim.rlim_cur != RLIM_INFINITY && rlim.rlim_cur < theMax))
518 {rlim.rlim_cur = theMax;
519 setrlimit(RLIMIT_NPROC, &rlim);
520 }
521 } else {
522 if (rlim.rlim_cur != rlim.rlim_max)
523 {rlim.rlim_cur = rlim.rlim_max;
524 setrlimit(RLIMIT_NPROC, &rlim);
525 }
526 }
527 }
528
529// Readjust our internal maximum to be the actual maximum
530//
531 if (!getrlimit(RLIMIT_NPROC, &rlim))
532 {if (rlim.rlim_cur == RLIM_INFINITY || rlim.rlim_cur > theMax)
533 max_Workers = static_cast<int>(theMax);
534 else max_Workers = static_cast<int>(rlim.rlim_cur);
535 }
536
537// The above may allow way too many threads. We make sure that the default
538// maximum threads is adhered to.
539//
540 if (max_Workers > DFL_SCHED_PROCS) max_Workers = DFL_SCHED_PROCS;
541#endif
542}
#define close(a)
Definition XrdPosix.hh:48
#define open
Definition XrdPosix.hh:76
#define read(a, b, c)
Definition XrdPosix.hh:82
#define DFL_SCHED_PROCS
#define MAX_SCHED_PROCS

References close, DFL_SCHED_PROCS, MAX_SCHED_PROCS, open, and read.

Referenced by XrdConfig::XrdConfig().

+ Here is the caller graph for this function:

◆ setParms()

void XrdScheduler::setParms ( int minw,
int maxw,
int avlt,
int maxi,
int once = 0 )

Definition at line 548 of file XrdScheduler.cc.

549{
550 static int isSet = 0;
551
552// Lock the data area and check for 1-time set
553//
554 SchedMutex.Lock();
555 if (once && isSet) {SchedMutex.UnLock(); return;}
556 isSet = 1;
557
558// get a consistent view of all the values
559//
560 if (maxw <= 0) maxw = max_Workers;
561 if (minw < 0) minw = min_Workers;
562 if (minw > maxw) minw = maxw;
563 if (avlw < 0) avlw = maxw/4*3;
564 else if (avlw > maxw) avlw = maxw;
565
566// Set the values
567//
568 min_Workers = minw;
569 max_Workers = maxw;
570 stk_Workers = maxw - avlw;
571 if (maxi >=0) max_Workidl = maxi;
572
573// Unlock the data area
574//
575 SchedMutex.UnLock();
576
577// If we have an idle interval, schedule the idle check
578//
579 if (maxi > 0)
580 {Cancel((XrdJob *)this);
581 Schedule((XrdJob *)this, (time_t)maxi+time(0));
582 }
583
584// Debug the info
585//
586 TRACE(SCHED,"Set min_Workers=" <<min_Workers <<" max_Workers=" <<max_Workers);
587 TRACE(SCHED,"Set stk_Workers=" <<stk_Workers <<" max_Workidl=" <<max_Workidl);
588}

References Cancel(), XrdSysMutex::Lock(), Schedule(), TRACE, and XrdSysMutex::UnLock().

+ Here is the call graph for this function:

◆ Start()

void XrdScheduler::Start ( )

Definition at line 594 of file XrdScheduler.cc.

595{
596 int retc, numw;
597 pthread_t tid;
598
599// Provide ABI compatibility for XrdOucTrace which is deprecated!
600//
601 if (getenv("XRDDEBUG") != 0) XrdTrace->What = TRACE_SCHED;
602 else if (XrdTraceOld) XrdTrace->What |= XrdTraceOld->What;
603
604// Start a time based scheduler
605//
606 if ((retc = XrdSysThread::Run(&tid, XrdStartTSched, (void *)this,
607 XRDSYSTHREAD_BIND, "Time scheduler")))
608 XrdLog->Emsg("Scheduler", retc, "create time scheduler thread");
609
610// If we an idle interval, schedule the idle check
611//
612 if (max_Workidl > 0) Schedule((XrdJob *)this, (time_t)max_Workidl+time(0));
613
614// Start 1/3 of the minimum number of threads
615//
616 if (!(numw = min_Workers/3)) numw = 2;
617 while(numw--) hireWorker(0);
618
619// Unlock the data area
620//
621 TRACE(SCHED, "Starting with " <<num_Workers <<" workers" );
622}
void * XrdStartTSched(void *carg)
#define XRDSYSTHREAD_BIND

References XrdSysError::Emsg(), XrdSysThread::Run(), Schedule(), TRACE, TRACE_SCHED, XrdOucTrace::What, XrdSysTrace::What, XrdLog, XrdStartTSched(), and XRDSYSTHREAD_BIND.

Referenced by XrdOssCsi::Init(), and XrdOucGetCache().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Stats()

int XrdScheduler::Stats ( char * buff,
int blen,
int do_sync = 0 )

Definition at line 628 of file XrdScheduler.cc.

629{
630 int cnt_Jobs, cnt_JobsinQ, xam_QLength, cnt_Workers, cnt_idl;
631 int cnt_TCreate, cnt_TDestroy, cnt_Limited;
632 static char statfmt[] = "<stats id=\"sched\"><jobs>%d</jobs>"
633 "<inq>%d</inq><maxinq>%d</maxinq>"
634 "<threads>%d</threads><idle>%d</idle>"
635 "<tcr>%d</tcr><tde>%d</tde>"
636 "<tlimr>%d</tlimr></stats>";
637
638// If only length wanted, do so
639//
640 if (!buff) return sizeof(statfmt) + 16*8;
641
642// Get values protected by the Dispatch lock (avoid lock if no sync needed)
643//
644 if (do_sync) DispatchMutex.Lock();
645 cnt_idl = idl_Workers;
646 if (do_sync) DispatchMutex.UnLock();
647
648// Get values protected by the Scheduler lock (avoid lock if no sync needed)
649//
650 if (do_sync) SchedMutex.Lock();
651 cnt_Workers = num_Workers;
652 cnt_Jobs = num_Jobs;
653 cnt_JobsinQ = num_JobsinQ;
654 xam_QLength = max_QLength;
655 cnt_TCreate = num_TCreate;
656 cnt_TDestroy= num_TDestroy;
657 cnt_Limited = num_Limited;
658 if (do_sync) SchedMutex.UnLock();
659
660// Format the stats and return them
661//
662 return snprintf(buff, blen, statfmt, cnt_Jobs, cnt_JobsinQ, xam_QLength,
663 cnt_Workers, cnt_idl, cnt_TCreate, cnt_TDestroy,
664 cnt_Limited);
665}

References XrdSysMutex::Lock(), max_QLength, num_Jobs, num_Limited, num_TCreate, num_TDestroy, and XrdSysMutex::UnLock().

Referenced by XrdConfig::XrdConfig().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ TimeSched()

void XrdScheduler::TimeSched ( )

Definition at line 671 of file XrdScheduler.cc.

672{
673 XrdJob *jp;
674 int wtime;
675
676// Continuous loop until we find some work here
677//
678 do {TimerMutex.Lock();
679 if (TimerQueue) wtime = TimerQueue->SchedTime-time(0);
680 else wtime = 60*60;
681 if (wtime > 0)
682 {TimerMutex.UnLock();
683 TimerRings.Wait(wtime);
684 } else {
685 jp = TimerQueue;
686 TimerQueue = jp->NextJob;
687 Schedule(jp);
688 TimerMutex.UnLock();
689 }
690 } while(1);
691}

References XrdSysMutex::Lock(), XrdJob::NextJob, Schedule(), XrdSysMutex::UnLock(), and XrdSysCondVar::Wait().

Referenced by XrdStartTSched().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ max_QLength

int XrdScheduler::max_QLength

Definition at line 84 of file XrdScheduler.hh.

Referenced by Schedule(), Schedule(), and Stats().

◆ num_Jobs

int XrdScheduler::num_Jobs

Definition at line 83 of file XrdScheduler.hh.

Referenced by Schedule(), Schedule(), and Stats().

◆ num_Limited

int XrdScheduler::num_Limited

Definition at line 85 of file XrdScheduler.hh.

Referenced by Stats().

◆ num_TCreate

int XrdScheduler::num_TCreate

Definition at line 81 of file XrdScheduler.hh.

Referenced by Stats().

◆ num_TDestroy

int XrdScheduler::num_TDestroy

Definition at line 82 of file XrdScheduler.hh.

Referenced by Run(), and Stats().


The documentation for this class was generated from the following files: