summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Sched/Scheduler_Generic.h
blob: 181a4307093235a64e008c69763106287ee97d80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/* -*- C++ -*- */
// $Id$
//
// ============================================================================
//
// = LIBRARY
//    sched
//
// = FILENAME
//    Scheduler_Generic.h
//
// = CREATION DATE
//    19 November 1997
//
// = AUTHOR
//    David Levine
//
// ============================================================================

#ifndef SCHEDULER_INTERNAL_H
#define SCHEDULER_INTERNAL_H

#include "Scheduler.h"

class TAO_ORBSVCS_Export Scheduler_Generic : public ACE_Scheduler
  // = TITLE
  //    Implementation of an off-line scheduler.
  //
  // = DESCRIPTION
  //    Schedules tasks, assigning the same priority to all of them.
{
public:
  Scheduler_Generic ();
  virtual ~Scheduler_Generic ();

  // = Initialize the scheduler.
  virtual void init (const int minimum_priority,
                     const int maximum_priority,
                     const char *runtime_filename = 0,
                     const char *rt_info_filename = 0,
                     const char *timeline_filename = 0);

  // = Registers a task.
  virtual status_t register_task (RT_Info *[],
                                  const u_int number_of_modes,
                                  handle_t &handle);

  virtual status_t lookup_rt_info (handle_t handle,
                                   RT_Info* &rtinfo);
  // Obtains an RT_Info based on its "handle".

  virtual status_t lookup_config_info (Preemption_Priority priority,
                                       Config_Info* &config_info);
  // Obtains a Config_Info based on its priority.

  // = Computes the schedule.
  virtual status_t 
    schedule (ACE_Unbounded_Set<Scheduling_Anomaly *> &anomaly_set);

  // = Access a thread priority.
  virtual int priority (const handle_t handle,
                        OS_Thread_Priority &priority,
                        Sub_Priority &subpriority,
                        Preemption_Priority &preemption_prio,
                        const mode_t = CURRENT_MODE) const;
  // Defines "priority" as the priority that was assigned to the Task that
  // was assigned "handle", for the specified mode.  Defines "subpriority"
  // as the relative ordering (due to dependencies) within the priority.
  // Returns 0 on success, or 1 if an invalid mode or handle are supplied.

private:
  u_int handles_;
  // The number of task handles dispensed so far.

  int minimum_priority_;
  // The minimum priority value that the application specified (in
  // its call to init ()).

  int maximum_priority_;
  // The maximum priority value that the application specified (in
  // its call to init ()).

  const char *runtime_filename_;
  // Destination file of Scheduler output from the configuration run.

  const char *rt_info_filename_;
  // Destination file of all rt_info data from the configuration run.

  const char *timeline_filename_;
  // The destination of the timeline.

  int increasing_priority_;
  // Set to 1 if priority values increase with increasing priority,
  // such as on Solaris and Win32, or 0 if they decrease, such as on
  // VxWorks.

  ACE_Unbounded_Set <RT_Info **> task_entries_;
  // Collection of known tasks.

  Config_Info config_info_;
  // dispatchin configuration info

#if defined (ACE_HAS_THREADS)
  typedef ACE_Recursive_Thread_Mutex LOCK;
#else
  typedef ACE_Null_Mutex LOCK;
#endif /* ACE_HAS_THREADS */

  LOCK lock_;
  // This protects access to the scheduler during configuration runs.


  ///////////////////////////////////////
  // member functions for internal use //
  ///////////////////////////////////////

  void reset ();
  // Prepare for another schedule computation, but do not
  // disturb the "output" (priorities that have already been assigned).

  void print_schedule ();
  // Display the schedule, task-by-task.

  ACE_UNIMPLEMENTED_FUNC (Scheduler_Generic (const Scheduler_Generic &))
  ACE_UNIMPLEMENTED_FUNC (Scheduler_Generic &operator= (
    const Scheduler_Generic &))
};


#if defined (__ACE_INLINE__)
#include "Scheduler_Generic.i"
#endif /* __ACE_INLINE__ */

#endif /* SCHEDULER_INTERNAL_H */


// EOF