D1.2: Configurable Cluster Schedulers Interface of...

45
Author: Louis Rilling Kerlabs 30. June 2010 This work is founded under the ARPEGE programme Three partners are involved

Transcript of D1.2: Configurable Cluster Schedulers Interface of...

  • Con�gurable Cluster Schedulers Interface of

    Kerrighed

    D1.2

    Author:Louis Rilling

    Kerlabs

    30. June 2010

    This work is founded under the ARPEGE programme

    Three partners are involved

  • Contents1 Introduction 1

    2 Overview of the Schedulers Framework 22.1 Notions of Scheduler Components . . . . . . . . . . . . . . . . . . . . . . 22.2 Objectives of the Framework . . . . . . . . . . . . . . . . . . . . . . . . . 22.3 Design and Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . 3

    3 Interfaces of the Schedulers Framework 83.1 ConfigFS Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    3.1.1 Components Creation and Linkage . . . . . . . . . . . . . . . . . . 83.1.2 Components Configuration . . . . . . . . . . . . . . . . . . . . . . 9

    3.2 API for Component Programmers . . . . . . . . . . . . . . . . . . . . . . 103.2.1 Probes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103.2.2 Schedulers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.2.3 Policies . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.2.4 Ports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.2.5 Filters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303.2.6 Process Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    I

  • D1.2 1. INTRODUCTION

    1 IntroductionIn this document we describe the interface of the configurable cluster schedulers serviceof Kerrighed[2]. Section 2 details the principles of configurable cluster schedulers in Ker-righed. The programming interfaces for scheduler designers are then detailed in Section3.

    1

  • D1.2 2. OVERVIEW OF THE SCHEDULERS FRAMEWORK

    2 Overview of the Schedulers FrameworkKerrighed provides a unique service of configurable cluster schedulers, which is based onprinciples presented in [4]. This service provides a framework to design, implement, anddynamically configure customized cluster schedulers, that is system services to manageresource utilization across the cluster. Kerrighed comes with two default schedulers thatimplement dynamic CPU load balancing through process migration, and static round-robinload balancing through remote fork().In this section we present the configurable cluster schedulers service. Programming andadministrators interfaces are detailed in Section 3.Kerrighed’s cluster schedulers are implemented by various types of components that ad-ministrators configure through the ConfigFS[1] virtual filesystem implemented in Linux.We first introduce the different notions of components of Kerrighed schedulers. Second wepresent the objectives of the configurable cluster schedulers framework. Finally we presentthe design and implementation of the framework.

    2.1 Notions of Scheduler ComponentsThe configurable scheduler framework of Kerrighed splits scheduler configuration in threemain types of components: probes, policies, and filters.A probe is an entity that extracts information from the runtime environment about a spe-cific aspect (e.g. CPU load and speed, total memory vs free memory, etc.). A probe col-lects information (data or events) and makes them available to other scheduler components.Scheduler designers can implement these probes as separate Linux kernel modules and in-sert them dynamically into the kernel. Probes may collect data already computed by thekernel (CPU average load for instance) or compute other data (alternative notion of CPUload, like the one of Mosix [3] for instance), thus extending the set of resource propertiesthat are being measured.A sheduling policy is an implementation of a process scheduling algorithm. In Kerrighed, ascheduling policy is in charge of selecting a proper node for a particular process. Schedul-ing policies base their decisions on data/events collected by probes. An example of ascheduling policy is a migration-based, sender-initiated load balancing policy. This policytakes resource properties from one or more probes as input and when it detects that thelocal load is higher than the loads of remote nodes, it tries to migrate processes to balancethe load.A filter is an intermediate entity taking data/events as input and producing a filtered output.Filters are useful to share probes between several scheduling policies and adapt the probes’outputs to each scheduling policy, or to implement modular features of a scheduler. Filterscan be chained to implement complex filters out of simple ones. Filters implement forinstance different caching policies of data collected from remote nodes, or block eventsunless the value of the event source exceeds a threshold.

    2.2 Objectives of the FrameworkThe main goal of Kerrighed’s scheduler framework is to provide administrators with highlyconfigurable scheduler configurations. For instance, if the administrator has to setup a newscheduler based on disk usage, he only implements a proper probe and plugs it to theframework at runtime. After that, he can start collecting the data about the disk usageimmediately. All these operations can be done without recompiling the operating systemkernel, and without even rebooting the cluster. The administrator should also be able tochange the set of locally measured resources very easily and thus adapt it to his currentneeds, local system load, etc.This goal induces three main modularity needs:

    2

  • D1.2 2.3 Design and Implementation

    • Allow administrators to build schedulers with building blocks.

    • Separate a scheduler architecture into basic functionalities that can be implementedby building blocks. The basic functionalities are probes, scheduling policies, andfilters.

    • Allow administrators to dynamically configure, connect, and disconnect buildingblocks at run time.

    For instance, an administrator should be able to build a process migration-based CPU loadbalancer out of two building blocks: a CPU probe measuring periodically the CPU loads ofthe nodes, and a generic migration-based load balancing scheduling policy. To do this, theadministrator uses the framework to configure both components, and simply connect themtogether. The administrator is then able, at runtime, to refine the scheduler, for instanceintroducing a filter relaying newly computed local load to the scheduling policy only ifit exceeds a threshold above which the performance of local processes may decrease, orchanging the period of CPU load computation to decrease the operating system overhead.Figure 1 shows an example of such a refined CPU load balancer, where the scheduling pol-icy selects candidate processes according to the load they induce. The scheduler was addeda threshold filter as just described in order to decrease the overhead of process scanningand comparisons between the local load and remote loads. Moreover, the scheduler wasadded a caching filter that decreases the overhead of retrieving the loads of remote nodes.Those last two building blocks could be added at anytime during the execution, and can bereconfigured, exchanged, or removed at anytime.

    Figure 1: Modularity of schedulers with probes, scheduling policies, and filters.

    To the three main needs just mentioned, for performance reasons, we added the constraintto implement the framework and all the scheduler components at kernel-level, the sched-uler components being implemented as loadable modules for the Kerrighed kernel. Themain performance issues are the overhead to frequently monitor system properties fromuserspace when they are computed as kernel-level state, provided that an interface exists,and efficient parsing of processes, for instance find a good candidate to migrate in order tobalance the CPU load.

    2.3 Design and ImplementationKerrighed’s scheduler framework is very similar to the former Kerrighed scheduler frame-work [4]. Besides the implementation details, the main differences are the following:

    3

  • D1.2 2.3 Design and Implementation

    • the scheduler configuration is based on the ConfigFS virtual file system, instead ofXML files [4];

    • the new framework introduces filters, which are a generalization of local analyz-ers [4];

    • scheduling policies and filters can be instantiated in several schedulers at the sametime;

    • the new framework introduces process sets, which allow administrators to defineseveral schedulers and let each of them act only on configured sets of processes,

    • the new framework introduces node sets, which allow administrators to restrict theset of nodes controlled by schedulers.

    The ConfigFS [1] virtual file system provides a file-system based user interface to create,configure, and destroy kernel objects. The root of the ConfigFS file system provides onedirectory for each registered subsystem. Each of these directories and sub-directories rep-resents a kernel object. All file entries in a directory represent object attributes. To createan object, the user simply calls the mkdir() system call, for instance using the mkdir shellcommand. Similarly, to get or set the value of an object’s attribute, the user simply calls theread() and write() system calls, for instance using the cat and echo shell commands. Ker-nel objects can be created under other kernel objects as sub-directories, or linked togetherthrough symbolic links from one object directory to a file entry in another object’s directory.Finally, kernel objects are destroyed by simply removing their representing directories.Figure 2 shows the file system view of the scheduler presented in Figure 1. Directory namesin light are created by user actions, while the other ones are automatically created by thescheduler framework. Solid arrows represent the directory hierarchy (light arrows resultingfrom user actions), and dotted arrows represent symbolic links (always created by the user).

    Figure 2: ConfigFS layout of Figure 1 scheduler.

    From the just mentioned properties of ConfigFS, the scheduler framework implements allits needed dynamic configurability interfaces using the ConfigFS interface and the auto-matic module loading feature of the Linux kernel. Components are represented as kernelobjects (directories in ConfigFS), and are linked either by creating a component under thedirectory of another one (see the description of filters below), or by drawing a symbolic

    4

  • D1.2 2.3 Design and Implementation

    link from one component directory to an entry in another component directory (see thedescription of probes below). The name of the kernel module implementing a componentis derived from the directory name of the component when it is created, which enables thescheduler framework to automatically load the needed kernel modules on demand.The framework automatically replicates the scheduler configuration on all nodes, by sim-ply re-playing file system accesses on the ConfigFS file system of the other nodes. Thisautomatic replication scheme results from the design choice of implementing schedulingpolicies with decentralized algorithms. In particular, the components of a scheduler mainlymonitor and act on local resources only (for instance, migrate a local process to anothernode), but can also query information from components on other nodes (for instance, theCPU load).

    Figure 3: Big picture of the configurable scheduler framework.

    Figure 3 show the five component types of the scheduler framework:

    • probes,

    • scheduling policies,

    • filters,

    • schedulers,

    • and process sets.

    Probes, scheduling policies, and filters are implemented as Linux kernel modules that aredynamically loaded when the first component that they implement is instantiated, and un-loaded when no component that they implement exist anymore in the configured sched-ulers. Schedulers and process sets are generic components implemented by the framework.In the scheduler framework, the interfaces for data/event flows are derived from the con-cepts of sources (implemented by probe sources and filters) and sinks (implemented byfilters and by scheduling policies ports). Sources produce data and/or events, that are re-trieved by sinks. Sources can publish events (for instance to notify new values of theirdata) for which sinks define notify methods called update_value(), and sinks can collectdata from sources using the get_value() methods of sources. To protect against dynamicremovals of components, a component never directly refers to a connected component butinstead always calls functions of the framework that will in turn call methods of the con-nected component with the needed precautions.

    5

  • D1.2 2.3 Design and Implementation

    A probe is created by creating a directory having the same name as the module implement-ing the probe in the probes/ directory of the krg_scheduler/ sub-system in ConfigFS.Every probe contains a set of data/event sources defined by the designer, and representedas sub-directories of the probe in ConfigFS. Probe sources are linked to sinks (filters orscheduling policies ports) by drawing symbolic links from their representing directory toarbitrary-named entries in the sinks’ directories. Probes doing periodic measures define aperform_measurement() method that will be called periodically by the framework usingthe period configured for the probe.Scheduling policies provide a new_task_node() method in order to choose the target nodewhen the fork() system call is called. They collect their information using ports, that aresub-directories implementing sinks. Scheduling policies also provide an update_node_set()method to be notified of changes in the scheduler’s node set (see below).A filter is represented by a directory, and implements a source, connected to a schedulingpolicy port or to another filter sink, and a sink that can be connected either to a filter sourceor to a probe source. To connect a port (resp. filter sink) to a filter source, the administratorcreates a sub-directory in the port’s (resp. filter sink’s) directory, which creates a new filterand connects it to the port (resp. filter sink).Schedulers are the top-level components of the framework. A scheduler associates a schedul-ing policy to a set of processes on a set of nodes in the cluster. A new scheduler iscreated by creating a directory (e.g. CPU_LB/) under the schedulers/ directory of thekrg_scheduler/ sub-system in ConfigFS. The scheduling policy of a scheduler is cre-ated by creating a sub-directory in the scheduler’s directory, this sub-directory having thesame name as the module implementing the policy (e.g. load_balancing/).The process set, configured in the process_set/ sub-directory of the scheduler, allowsthe administrator to configure which processes are controlled by the scheduler. Processescan be controlled by putting their UNIX Process ID, Process Group ID, or process SessionID in the process set.The node set, configured by three attributes of a scheduler called node_set, node_set_exclusive,and node_set_max_fit, allows the administrator to restrict the set of nodes on which con-trolled processes should run. This can be used for dynamic partitioning and re-partitioningof the cluster. For instance, Kerrighed’s default migration-based load balancing policyexpels all controlled processes from a node as soon as it is removed from the parent sched-uler’s process set. The node_set attribute contains the ids nodes in the node set, while thenode_set_exclusive attribute controls whether the node set can overlap with node setsof other schedulers, and the node_set_max_fit attribute controls whether the node setautomatically expands to nodes added to the cluster.Listing 2.3 shows a sample shell script that configures the scheduler depicted in figure 1.

    6

  • D1.2 2.3 Design and Implementation

    Listing 1: Sample shell script to configure a scheduler.

    SROOT=/ c o n f i g / k r g _ s c h e d u l e r

    PROBE=$SROOT / p r o b e s / cpu# l o a d k e r n e l module cpu . ko and a t i v a t e t h e p robemkdir $PROBE# make t h e probe n o t i f y u p d a t e s e v e r y secondecho 1000 > $PROBE / p r o b e _ p e r i o d

    SCHEDULER=$SROOT / s c h e d u l e r s / CPU_LB# c r e a t e a new s c h e d u l e r c a l l e d CPU_LBmkdir $SCHEDULER

    # l o a d k e r n e l module l o a d _ b a l a n c i n g . ko and i n s t a n t i a t e# a l o a d b a l a n c i n g p o l i c yPOLICY=$SCHEDULER / l o a d _ b a l a n c i n gmkdir $POLICY

    cd $POLICY / node_ load# l o a d k e r n e l module r e m o t e _ c a c h e . ko , i n s t a n t i a t e a# remote cache f i l t e r and make i t t h e s o u r c e o f# p o r t node_ loadmkdir r e m o t e _ c a c h e

    # l o a d k e r n e l module t h r e s h o l d . ko , i n s t a n t i a t e a# t h r e s h o l d f i l t e r and make i t t h e s o u r c e o f# f i l t e r r e m o t e _ c a c h emkdir r e m o t e _ c a c h e / t h r e s h o l d

    # s e t t h e f i l t e r ’ s t h r e s h o l dcd r e m o t e _ c a c h e / t h r e s h o l decho 100 > t h r e s h o l d

    # make probe s o u r c e node_ load t h e s o u r c e o f f i l t e r t h r e s h o l dln −s $PROBE / node_ load c p u _ l o a d

    # make probe s o u r c e p r o c e s s _ l o a d t h e s o u r c e o f# p o r t p r o c e s s _ l o a dcd $POLICY / p r o c e s s _ l o a dln −s $PROBE / p r o c e s s _ l o a d c p u _ l o a d

    # a t t a c h r u n n i n g Apache t o t h e s c h e d u l e rcd $SCHEDULER/ p r o c e s s _ s e tmkdir s i n g l e _ p r o c e s s e s / ‘ p i d o f apache ‘

    # a t t a c h a l l ( r u n n i n g and f u t u r e ) p r o c e s s e s o f# t h e c u r r e n t s e s s i o n t o t h e s c h e d u l e rmkdir p r o c e s s _ s e s s i o n s / ‘ ps h −o s i d $$ ‘

    7

  • D1.2 3. INTERFACES OF THE SCHEDULERS FRAMEWORK

    3 Interfaces of the Schedulers FrameworkThe schedulers framework of Kerrighed provides two levels of interface. A ConfigFS-based interface is provided to allow administrators to configure schedulers. A kernel-level,C API is provided to allow scheduler designers to program specific components (probes,policies, and filters).

    3.1 ConfigFS InterfaceThe ConfigFS interface allows to configure schedulers with two classes of actions:

    • create and link components together by creating directories and drawing symboliclinks, and

    • configure created components by writing to attribute files, or, in the case of processsets, by creating and removing sub-directories.

    Listing 2.3 shows an example usage of the ConfigFS interface.

    3.1.1 Components Creation and Linkage

    The configuration of schedulers is done under the krg_scheduler/ directory of any Con-figFS mountpoint (typically /config/ or /sys/kernel/config/). The krg_scheduler/directory contains two sub-directories:

    • the probes/ directory contains configured probes,

    • the schedulers/ directory contains configured schedulers with their policies andfilters.

    Probes To load a probe, one creates the directory having the probe’s module name underthe probes/ directory. The probe’s directory contains at least one sub-directory per probesource, and may contain other custom sub-directories.Probes have one default attribute called probe_period described in next section. Probesources have one default attribute called value, which exposes a textual representation ofthe value extracted by the probe source, if any. This is a read-only attribute.

    Schedulers To create a new scheduler, one creates a directory of arbitrary name underthe schedulers/ directory. The scheduler’s directory contains a process_set/ sub-directory, and the three attributes controlling the node set of the scheduler (node_set,node_set_exclusive, and node_set_max_fit). The process set and the node set arediscussed in next section.A policy is attached to a scheduler by creating a directory having the name of the moduleimplementing the policy. At most one policy can be attached to a scheduler at any time.The policy of a scheduler can however be removed and replaced by a other new one at anytime.Different schedulers using a same policy have each their own instance of the policy.

    Policies The ConfigFS layout of policies has no default entries. However, the recom-mended usage is that policies have sub-directories implementing ports, to which sources(filters or probe sources) can be connected.

    8

  • D1.2 3.1 ConfigFS Interface

    Ports Ports are default sub-directories of policies and filters that are defined by the pro-grammers of those policies and filters. Ports have only one attribute called collected_valuewhich exposes a textual representation of the value that can be read from its connectedsource, and is equivalent to the value attribute of the connected source. This is a read-onlyattribute.A port is connected to a source by either creating a filter as sub-directory, or drawing a linkfrom a probe source directory to an arbitrary named entry of the port’s directory. A portcannot have more that one source connected at the same time.

    Filters A filter implements both a source and a port in a single directory. As a result afilter contains the two default read-only attributes value and collected_value. In partic-ular, the transformation operated by filters that modify data can be observed by comparingthe contents of those two attributes. A filter is also connected to a source the same way andwith the same constraints as a port.Filters may contain custom sub-directories (including ports) and attributes.

    3.1.2 Components Configuration

    Configured schedulers have three classes of tunables:

    • ConfigFS attributes (see all echo commands in the sample shell script 2.3),

    • impacted processes (the process_set/ sub-directory of a scheduler directory),

    • and impacted nodes (all node_set* attributes of a scheduler directory).

    ConfigFS Attributes Scheduler directories contain various attributes, some of which canbe used to tune the schedulers components. Default tunable attributes exist for probes(described below) and top scheduler component (described in the following paragraphs).Scheduler modules may also define custom ConfigFS attributes with custom meanings.Probes contain the probe_period default attribute. This attribute contains the period inmilli-seconds at which the probe should refresh and publish its data. Only probes defininga perform_measurement() method use this attribute.

    Process Sets The process_set/ sub-directory of a scheduler allows one to controlwhich processes will be controlled by this scheduler. Process sets are allowed to overlap,and no mechanism is provided to prevent conflicting decisions from different schedulers.The process_set/ directory contains the handle_all attribute and three sub-directories :single_processes/, process_groups/, and process_sessions/.The handle_all attribute is a boolean that can be used to put all processes of the clusterunder control of the scheduler. The default schedulers of Kerrighed do this.If handle_all is false (ie 0), processes that should be controlled by the scheduler must beexplicitly listed using the single_processes/, process_groups/, and process_sessions/sub-directories. Each of these directories contains one sub-directory per PID (resp. PGID,SID) of the processes (resp. UNIX process groups, UNIX process sessions) explicitly con-trolled. An existing process (resp. process group, process session) is added by simplycreating the sub-directory.Note that only already running processes can be added to single_processes/. Creatingan entry for a PID that does not exist is permitted, but a future process using this PID willnot be controlled by the scheduler. Likewise process_groups/ and process_sessions/will only act on entries referring to existing process groups and sessions when they wereadded. However, any new process (resp. process group) in a controlled process group (resp.process session) will be controlled by the scheduler.

    9

  • D1.2 3.2 API for Component Programmers

    Node Sets The node_set attribute is used by default Kerrighed policies as the set ofnodes on which controlled processes are allowed to run. Other scheduling policies canuse it differently. It’s format is: [,

  • D1.2 3.2 API for Component Programmers

    /∗ ∗∗ Mandatory macro t o d e f i n e a s c h e d u l e r _ p r o b e _ a t t r i b u t e .∗∗ @param v a r v a r i a b l e name of t h e s c h e d u l e r _ p r o b e _ a t t r i b u t e∗ @param name e n t r y name of t h e a t t r i b u t e i n t h e p robe d i r e c t o r y∗ @param mode a c c e s s mode of t h e a t t r i b u t e e n t r y∗ @param _show show c a l l b a c k of t h e a t t r i b u t e∗ @param _ s t o r e s t o r e c a l l b a c k of t h e a t t r i b u t e∗ /

    # d e f i n e SCHEDULER_PROBE_ATTRIBUTE( var , name , mode , _show , _ s t o r e )

    /∗ ∗ s t r u c t which c o n t a i n s each probe ’ s o p e r a t i o n s . ∗ //∗∗ To i n i t i a l i z e wi th SCHEDULER_PROBE_TYPE . The probe subsys t em c o m p l e t e s t h i s∗ i n i t .∗ /

    s t r u c t s c h e d u l e r _ p r o b e _ t y p e {s t r u c t c o n f i g _ i t e m _ t y p e i t e m _ t y p e ;void (∗ per fo rm_measurement ) ( void ) ; /∗ ∗ f u n c t i o n f o r p e r f o r m i n g r e s o u r c e

    ∗ measurement on ly p e r i o d i c a l l y .∗ Thi s f u n c t i o n i s s u i t a b l e f o r∗ measu r ing dynamic r e s o u r c e∗ p r o p e r t i e s . ∗ /

    s t r u c t s c h e d u l e r _ p r o b e _ a t t r i b u t e ∗∗ a t t r s ; /∗ ∗ NULL−t e r m i n a t e d a r r a y o f∗ custom a t t r i b u t e s ∗ /

    } ;

    /∗ ∗∗ Mandatory macro t o d e f i n e a s c h e d u l e r _ p r o b e _ t y p e .∗∗ @param name Name of t h e v a r i a b l e c o n t a i n i n g t h e p robe t y p e .∗ @param _ a t t r s NULL−t e r m i n a t e d a r r a y o f custom a t t r i b u t e s , o r∗ NULL∗ @param _per fo rm_measurement∗ F u n c t i o n t o use f o r p e r i o d i c measurement and s u b s c r i b e r s∗ r e f r e s h m e n t , o r NULL∗ /

    # d e f i n e SCHEDULER_PROBE_TYPE( name , _ a t t r s , _per fo rm_measurement )

    # d e f i n e SCHEDULER_PROBE_SOURCE_ATTR_SIZE 4096

    /∗∗ To d e f i n e wi th SCHEDULER_PROBE_SOURCE_ATTRIBUTE∗ S t r u c t u r e r e p r e s e n t i n g a custom probe s o u r c e a t t r i b u t e∗ /

    s t r u c t s c h e d u l e r _ p r o b e _ s o u r c e _ a t t r i b u t e {s t r u c t c o n f i g f s _ a t t r i b u t e c o n f i g ; /∗ ∗ r e p r e s e n t a t i o n o f a t t r i b u t e i n

    ∗ c o n f i g f s . ∗ /s s i z e _ t (∗ show ) ( char ∗ ) ; /∗ ∗ Method t o r e a d t h e a t t r i b u t e i n

    ∗ c o n f i g f s ∗ /s s i z e _ t (∗ s t o r e ) ( c o n s t char ∗ , s i z e _ t ) ; /∗ ∗ Method t o modify t h e

    ∗ a t t r i b u t e wi th c o n f i g f s ∗ /} ;

    11

  • D1.2 3.2 API for Component Programmers

    /∗ ∗∗ Mandatory macro t o d e f i n e a s c h e d u l e r _ p r o b e _ s o u r c e _ a t t r i b u t e .∗∗ @param v a r v a r i a b l e name of t h e s c h e d u l e r _ p r o b e _ s o u r c e _ a t t r i b u t e .∗ @param name e n t r y name of t h e a t t r i b u t e i n t h e p robe s o u r c e∗ d i r e c t o r y∗ @param mode a c c e s s mode of t h e a t t r i b u t e e n t r y∗ @param _show show c a l l b a c k of t h e a t t r i b u t e∗ @param _ s t o r e s t o r e c a l l b a c k of t h e a t t r i b u t e∗ /

    # d e f i n e SCHEDULER_PROBE_SOURCE_ATTRIBUTE( var , name , mode , _show , _ s t o r e )

    /∗∗ To i n i t i a l i z e wi th SCHEDULER_PROBE_SOURCE_TYPE_INIT ( p o s s i b l y t h r o u g h t h e∗ BEGIN_SCHEDULER_PROBE_SOURCE_TYPE h e l p e r )∗ The probe subsys t em c o m p l e t e s t h i s i n i t .∗ /

    s t r u c t s c h e d u l e r _ p r o b e _ s o u r c e _ t y p e {s t r u c t s c h e d u l e r _ s o u r c e _ t y p e s o u r c e _ t y p e ;s t r u c t s c h e d u l e r _ p i p e _ t y p e p i p e _ t y p e ;i n t (∗ has_changed ) ( void ) ; /∗ ∗ r e t u r n s 1 , i f a t t r i b u t e v a l u e has

    ∗ changed s i n c e l a s t measurement ,∗ o t h e r w i s e r e t u r n s 0 . You a l s o have∗ t o u p d a t e p r e v i o u s v a l u e h e r e . ∗ /

    s t r u c t s c h e d u l e r _ p r o b e _ s o u r c e _ a t t r i b u t e ∗∗ a t t r s ;} ;

    /∗ ∗∗ Mandatory macro t o d e f i n e a s c h e d u l e r _ p r o b e _ s o u r c e _ t y p e∗∗ @param v a r v a r i a b l e c o n t a i n i n g t h e s c h e d u l e r _ p r o b e _ s o u r c e _ t y p e∗ @param owner module owning t h e s c h e d u l e r _ p r o b e _ s o u r c e _ t y p e∗ @param a t t r s n o t used y e t∗ @param g e t _ v a l u e g e t _ v a l u e ( ) method of t h e s c h e d u l e r _ p r o b e _ s o u r c e , o r∗ NULL∗ @param show_value show_value ( ) method of t h e s c h e d u l e r _ p r o b e _ s o u r c e , o r∗ NULL∗ @param v a l u e _ t y p e s t r i n g c o n t a i n i n g t h e t y p e name of∗ s c h e d u l e r _ p r o b e _ s o u r c e ’ s v a l u e s∗ @param v a l u e _ t y p e _ s i z e∗ s i z e i n b y t e s o f a v a l u e _ t y p e v a l u e∗ @param g e t _ p a r a m _ t y p e∗ s t r i n g c o n t a i n i n g t h e t y p e name of t h e p a r a m e t e r s f o r∗ t h e g e t ( ) method , o r NULL∗ @param g e t _ p a r a m _ t y p e _ s i z e∗ s i z e i n b y t e s o f a g e t _ p a r a m _ t y p e p a r a m e t e r∗ @param _has_changed has_changed ( ) method of t h e s c h e d u l e r _ p r o b e _ s o u r c e , o r∗ NULL∗ /

    # d e f i n e SCHEDULER_PROBE_SOURCE_TYPE_INIT( var , owner , a t t r s ,g e t _ v a l u e , show_value ,v a l u e _ t y p e , v a l u e _ t y p e _ s i z e ,ge t_pa ram_type , g e t _ p a r a m _ t y p e _ s i z e ,

    12

  • D1.2 3.2 API for Component Programmers

    _has_changed )

    /∗∗ S t r u c t u r e r e p r e s e n t i n g a probe s o u r c e . As a sou rce , a p robe s o u r c e implemen t s∗ s c h e d u l e r _ s o u r c e . As a d i r e c t o r y , a p robe s o u r c e implemen t s∗ s c h e d u l e r _ p i p e .∗ /

    s t r u c t s c h e d u l e r _ p r o b e _ s o u r c e ;

    /∗∗ Convenience macros t o d e f i n e a s c h e d u l e r _ p r o b e _ s o u r c e _ t y p e∗∗ These c o n v e n i e n c e macros s h o u l d be used t h e f o l l o w i n g way :∗∗ F i r s t , implemented methods must be d e f i n e d u s i n g t h e∗ DEFINE_SCHEDULER_PROBE_SOURCE_ macros . Second , t h e∗ s c h e d u l e r _ p r o b e _ s o u r c e _ t y p e must be f i l l e d u s i n g∗ {BEGIN ,END}_SCHEDULER_PROBE_SOURCE_TYPE and SCHEDULER_PROBE_SOURCE_∗ macros :∗ BEGIN_SCHEDULER_PROBE_SOURCE_TYPE( name ) ,∗ . SCHEDULER_PROBE_SOURCE_VALUE_TYPE( name , t y p e ) ,∗ i f needed :∗ . SCHEDULER_PROBE_SOURCE_( name ) ,∗ . SCHEDULER_PROBE_SOURCE_PARAM_TYPE( name , t y p e ) ,∗ . SCHEDULER_PROBE_SOURCE_ATTRS( name , a t t r s ) ,∗ and f i n a l l y :∗ END_SCHEDULER_PROBE_SOURCE_TYPE( name ) ;∗ /

    /∗ ∗∗ Convenience macro t o d e f i n e a t y p e d g e t ( ) method w i t h o u t a s o u r c e argument∗ and wi th p a r a m e t e r s . The t y p e d method w i l l be c a l l e d name_get . When c a l l e d∗ from t h e framework , t h e p robe s o u r c e l o c k i s h e l d .∗∗ @param name name of t h e p r o b e _ s o u r c e t y p e∗ @param t y p e t y p e o f t h e v a l u e s o u t p u t by t h e p robe s o u r c e ( eg . i n t )∗ @param p t r name of t h e t y p e ∗ a r g o f t h e method∗ @param nr name of t h e a r r a y l e n g t h p a r a m e t e r o f t h e method∗ @param i n _ t y p e t y p e o f t h e p a r a m e t e r s o f t h e method ( eg . i n t )∗ @param i n _ p t r name of t h e i n _ t y p e ∗ a r g o f t h e method∗ @param i n _ n r name of t h e p a r a m e t e r s a r r a y l e n g t h a r g o f t h e method∗ /

    # d e f i n e DEFINE_SCHEDULER_PROBE_SOURCE_GET_WITH_INPUT( name , type , p t r , nr ,i n _ t y p e , i n _ p t r , i n _ n r )

    /∗ ∗∗ Convenience macro t o d e f i n e a t y p e d g e t ( ) method w i t h o u t a s o u r c e argument∗ and wi th no p a r a m e t e r s . The t y p e d method w i l l be c a l l e d name_get . When c a l l e d∗ from t h e framework , t h e p robe s o u r c e l o c k i s h e l d .∗∗ @param name name of t h e s c h e d u l e r _ p r o b e _ s o u r c e t y p e∗ @param t y p e t y p e o f t h e v a l u e s o u t p u t by t h e p robe s o u r c e ( eg . i n t )∗ @param p t r name of t h e t y p e ∗ a r g o f t h e method∗ @param nr name of t h e a r r a y l e n g t h p a r a m e t e r o f t h e method∗ /

    13

  • D1.2 3.2 API for Component Programmers

    # d e f i n e DEFINE_SCHEDULER_PROBE_SOURCE_GET( name , type , p t r , n r )

    /∗ ∗∗ Convenience macro t o d e f i n e a show ( ) method w i t h o u t a s o u r c e argument . The∗ method w i l l be c a l l e d name_show . When c a l l e d from t h e framework , t h e p robe∗ s o u r c e l o c k i s h e l d .∗∗ @param name name of t h e s c h e d u l e r _ p r o b e _ s o u r c e t y p e∗ @param page name of t h e b u f f e r a r g o f t h e method∗ /

    # d e f i n e DEFINE_SCHEDULER_PROBE_SOURCE_SHOW( name , page )

    /∗ ∗∗ Convenience macro t o d e f i n e a has_changed ( ) method .∗ The method w i l l be c a l l e d name_has_changed .∗∗ @param name name of t h e s c h e d u l e r _ p r o b e _ s o u r c e t y p e∗ /

    # d e f i n e DEFINE_SCHEDULER_PROBE_SOURCE_HAS_CHANGED( name )

    /∗ ∗∗ Convenience macro t o s t a r t t h e d e f i n i t i o n o f a s c h e d u l e r _ p r o b e _ s o u r c e _ t y p e .∗ The d e f i n i t i o n must end wi th END_SCHEDULER_PROBE_SOURCE_TYPE( name ) . The∗ v a r i a b l e w i l l be c a l l e d name_type .∗∗ @param name name of t h e s c h e d u l e r _ p r o b e _ s o u r c e t y p e∗ /

    # d e f i n e BEGIN_SCHEDULER_PROBE_SOURCE_TYPE( name )

    /∗ ∗∗ Convenience macro t o a t t a c h custom probe s o u r c e a t t r i b u t e s t o a p robe s o u r c e∗ t y p e .∗∗ @param name must match t h e name used wi th∗ BEGIN_SCHEDULER_PROBE_SOURCE_TYPE∗ @param _ a t t r s NULL t e r m i n a t e d a r r a y o f p o i n t e r s t o custom probe s o u r c e∗ a t t r i b u t e s ( s t r u c t s c h e d u l e r _ p r o b e _ s o u r c e _ a t t r i b u t e )∗ /

    # d e f i n e SCHEDULER_PROBE_SOURCE_ATTRS( name , _ a t t r s )

    /∗ ∗∗ Convenience macro t o a t t a c h a p r e v i o u s l y d e f i n e d g e t ( ) method t o a p robe∗ s o u r c e t y p e . The g e t ( ) method must have been d e f i n e d e a r l i e r w i th∗ DEFINE_SCHEDULER_PROBE_SOURCE_GET[ _WITH_INPUT ] ( name , . . . ) . The v a l u e t y p e∗ ( and p a r a m e t e r t y p e i f used ) must be a t t a c h e d wi th∗ SCHEDULER_PROBE_SOURCE_VALUE_TYPE( name , . . . ) ( r e sp ,∗ SCHEDULER_PROBE_SOURCE_PARAM_TYPE( name , . . . ) ) .∗∗ @param name must match t h e name used wi th∗ BEGIN_SCHEDULER_PROBE_SOURCE_TYPE∗ /

    # d e f i n e SCHEDULER_PROBE_SOURCE_GET( name )

    /∗ ∗

    14

  • D1.2 3.2 API for Component Programmers

    ∗ Convenience macro t o a t t a c h a p r e v i o u s l y d e f i n e d show ( ) method t o a p robe∗ s o u r c e t y p e . The show ( ) method must have been d e f i n e d e a r l i e r w i th∗ DEFINE_SCHEDULER_PROBE_SOURCE_SHOW( name , . . . ) .∗∗ @param name must match t h e name used wi th∗ BEGIN_SCHEDULER_PROBE_SOURCE_TYPE∗ /

    # d e f i n e SCHEDULER_PROBE_SOURCE_SHOW( name )

    /∗ ∗∗ Convenience macro t o d e c l a r e t h e v a l u e t y p e o f a p robe s o u r c e . Must be used∗ w i t h i n a l l BEGIN_SCHEDULER_PROBE_SOURCE_TYPE s e c t i o n s .∗∗ @param name must match t h e name used wi th∗ BEGIN_SCHEDULER_PROBE_SOURCE_TYPE∗ @param t y p e l i t t e r a l e x p r e s s i o n o f t h e v a l u e t y p e o u t p u t∗ /

    # d e f i n e SCHEDULER_PROBE_SOURCE_VALUE_TYPE( name , t y p e )

    /∗ ∗∗ Convenience macro t o d e c l a r e t h e p a r a m e t e r t y p e o f t h e g e t ( ) method of a∗ probe s o u r c e .∗∗ @param name must match t h e name used wi th∗ BEGIN_SCHEDULER_PROBE_SOURCE_TYPE∗ @param t y p e l i t t e r a l e x p r e s s i o n o f t h e p a r a m e t e r t y p e∗ /

    # d e f i n e SCHEDULER_PROBE_SOURCE_PARAM_TYPE( name , t y p e )

    /∗ ∗∗ Convenience macro t o a t t a c h a p r e v i o u s l y d e f i n e d has_changed ( ) method t o a∗ probe s o u r c e t y p e . The has_changed ( ) method must have been d e f i n e d e a r l i e r∗ wi th DEFINE_SCHEDULER_PROBE_SOURCE_HAS_CHANGED( name ) .∗∗ @param name must match t h e name used wi th∗ BEGIN_SCHEDULER_PROBE_SOURCE_TYPE∗ /

    # d e f i n e SCHEDULER_PROBE_SOURCE_HAS_CHANGED( name )

    /∗ ∗∗ End t h e d e f i n i t i o n o f a s c h e d u l e r _ p r o b e _ s o u r c e _ t y p e . Must c l o s e any∗ BEGIN_SCHEDULER_PROBE_SOURCE_TYPE s e c t i o n .∗∗ @param name must match t h e name used wi th∗ BEGIN_SCHEDULER_PROBE_SOURCE_TYPE∗ /

    # d e f i n e END_SCHEDULER_PROBE_SOURCE_TYPE( name )

    /∗ End of c o n v e n i e n c e macros ∗ /

    /∗ ∗∗ Thi s f u n c t i o n a l l o c a t e s memory f o r new probe and i n i t i a l i z e s i t .∗ @author Marko Novak , Lou i s R i l l i n g∗

    15

  • D1.2 3.2 API for Component Programmers

    ∗ @param t y p e Type of t h e probe , d e f i n e d wi th SCHEDULER_PROBE_TYPE∗ @param name Name of t h e p robe . Th i s name must be u n i que f o r each∗ probe and must match t h e module f i l e name .∗ @param s o u r c e s NULL−t e r m i n a t e d a r r a y o f p robe ’ s s o u r c e s c r e a t e d wi th∗ s c h e d u l e r _ p r o b e _ s o u r c e _ c r e a t e ( ) .∗ @param d e f _ g r o u p s NULL−t e r m i n a t e d a r r a y o f s u b d i r s o f t h e p robe∗ d i r e c t o r y , o r NULL∗∗ @return p o i n t e r t o newly c r e a t e d probe o r NULL i f p robe∗ c r e a t i o n f a i l e d .∗ /

    s t r u c t s c h e d u l e r _ p r o b e ∗s c h e d u l e r _ p r o b e _ c r e a t e ( s t r u c t s c h e d u l e r _ p r o b e _ t y p e ∗ type ,

    c o n s t char ∗name ,s t r u c t s c h e d u l e r _ p r o b e _ s o u r c e ∗∗ s o u r c e s ,s t r u c t c o n f i g _ g r o u p ∗ d e f _ g r o u p s [ ] ) ;

    /∗ ∗∗ Thi s f u n c t i o n f r e e s a l l t h e memory t a k e n by a probe .∗ @author Marko Novak , Lou i s R i l l i n g∗∗ @param probe p o i n t e r t o p robe whose memory we want t o f r e e .∗ /

    void s c h e d u l e r _ p r o b e _ f r e e ( s t r u c t s c h e d u l e r _ p r o b e ∗ probe ) ;

    /∗ ∗∗ Thi s f u n c t i o n a l l o c a t e s memory and i n i t i a l i z e s a p robe s o u r c e .∗ @author Marko Novak , Lou i s R i l l i n g∗∗ @param t y p e Type d e s c r i b i n g t h e p robe sou rce , d e f i n e d wi th∗ SCHEDULER_PROBE_SOURCE_TYPE∗ @param name Name of t h e s o u r c e ’ s s u b d i r e c t o r y i n t h e p robe ’ s∗ d i r e c t o r y . Must be un i qu e f o r a g i v e n a probe .∗∗ @return P o i n t e r t o t h e c r e a t e d s c h e d u l e r _ p r o b e _ s o u r c e , o r∗ NULL i f e r r o r∗ /

    s t r u c t s c h e d u l e r _ p r o b e _ s o u r c e ∗s c h e d u l e r _ p r o b e _ s o u r c e _ c r e a t e ( s t r u c t s c h e d u l e r _ p r o b e _ s o u r c e _ t y p e ∗ type ,

    c o n s t char ∗name ) ;void s c h e d u l e r _ p r o b e _ s o u r c e _ f r e e ( s t r u c t s c h e d u l e r _ p r o b e _ s o u r c e ∗ s o u r c e ) ;

    /∗ ∗∗ Lock a probe s o u r c e . No s l e e p i s a l l o w e d w h i l e a p robe s o u r c e i s l o c k e d .∗ Thi s a c t u a l l y l o c k s t h e p robe c o n t a i n i n g t h i s s o u r c e .∗∗ @param p r o b e _ s o u r c e p robe s o u r c e t o l o c k∗ /

    void s c h e d u l e r _ p r o b e _ s o u r c e _ l o c k ( s t r u c t s c h e d u l e r _ p r o b e _ s o u r c e ∗ p r o b e _ s o u r c e ) ;/∗ ∗∗ Unlock a probe s o u r c e .∗∗ @param p r o b e _ s o u r c e p robe s o u r c e t o u n lo ck∗ /

    void s c h e d u l e r _ p r o b e _ s o u r c e _ u n l o c k ( s t r u c t s c h e d u l e r _ p r o b e _ s o u r c e ∗ p r o b e _ s o u r c e ) ;

    16

  • D1.2 3.2 API for Component Programmers

    /∗ ∗∗ F u n c t i o n t h a t a p robe s o u r c e s h o u l d c a l l when t h e v a l u e changes and t h e probe∗ does n o t have a per fo rm_measurement ( ) method .∗ Does n o t h i n g i f t h e p robe p r o v i d e s a per fo rm_measurement ( ) method .∗∗ @param s o u r c e Source ha v i ng been u p d a t e d∗ /

    voids c h e d u l e r _ p r o b e _ s o u r c e _ n o t i f y _ u p d a t e ( s t r u c t s c h e d u l e r _ p r o b e _ s o u r c e ∗ s o u r c e ) ;

    /∗ ∗∗ Thi s f u n c t i o n i s used f o r r e g i s t e r i n g probe . Th i s f u n c t i o n has t o∗ be c a l l e d a t t h e end of " i n i t _ m o d u l e " f u n c t i o n f o r each probe ’ s module .∗ @author Marko Novak , Lou i s R i l l i n g∗∗ @param probe p o i n t e r t o t h e p robe we wish t o r e g i s t e r .∗∗ @return 0 , i f p robe was s u c c e s s f u l l y r e g i s t e r e d .∗ −EEXIST , i f p robe wi th same name i s a l r e a d y r e g i s t e r e d .∗ /

    i n t s c h e d u l e r _ p r o b e _ r e g i s t e r ( s t r u c t s c h e d u l e r _ p r o b e ∗ probe ) ;

    /∗ ∗∗ Thi s f u n c t i o n i s used f o r removing probe r e g i s t r a t i o n . Th i s f u n c t i o n must∗ ∗ on ly ∗ be c a l l e d a t module u n l o a d i n g ( from " c leanup_module " f u n c t i o n ) .∗ @author Marko Novak , Lou i s R i l l i n g∗∗ @param probe p o i n t e r t o t h e p robe we wish t o u n r e g i s t e r .∗ /

    void s c h e d u l e r _ p r o b e _ u n r e g i s t e r ( s t r u c t s c h e d u l e r _ p r o b e ∗ probe ) ;

    /∗ ∗∗ Lock a probe . No s l e e p i s a l l o w e d w h i l e a p robe i s l o c k e d .∗∗ @param probe probe t o l o c k∗ /

    void s c h e d u l e r _ p r o b e _ l o c k ( s t r u c t s c h e d u l e r _ p r o b e ∗ probe ) ;/∗ ∗∗ Unlock a probe .∗∗ @param probe probe t o un lo ck∗ /

    void s c h e d u l e r _ p r o b e _ u n l o c k ( s t r u c t s c h e d u l e r _ p r o b e ∗ probe ) ;

    3.2.2 Schedulers

    The API of scheduler components can be found in kernel header .We provide here the public part of this header.

    s t r u c t s c h e d u l e r _ p o l i c y ;s t r u c t p r o c e s s _ s e t ;s t r u c t s c h e d u l e r ;

    17

  • D1.2 3.2 API for Component Programmers

    /∗ ∗∗ Get a r e f e r e n c e on a s c h e d u l e r∗∗ @param s c h e d u l e r s c h e d u l e r t o g e t a r e f e r e n c e on∗ /

    void s c h e d u l e r _ g e t ( s t r u c t s c h e d u l e r ∗ s c h e d u l e r ) ;/∗ ∗∗ Put a r e f e r e n c e on a s c h e d u l e r∗∗ @param s c h e d u l e r s c h e d u l e r t o p u t a r e f e r e n c e on∗ /

    void s c h e d u l e r _ p u t ( s t r u c t s c h e d u l e r ∗ s c h e d u l e r ) ;

    /∗ ∗∗ Get a r e f e r e n c e on t h e s c h e d u l e r owning a s c h e d u l e r _ p o l i c y∗ The r e f e r e n c e must be p u t w i th s c h e d u l e r _ p u t ( )∗∗ @param p o l i c y s c h e d u l i n g p o l i c y o f t h e s e a r c h e d s c h e d u l e r∗∗ @return s c h e d u l e r owning t h e s c h e d u l e r _ p o l i c y , o r∗ NULL i f t h e s c h e d u l e r _ p o l i c y i s n o t used anymore∗ /

    s t r u c t s c h e d u l e r ∗s c h e d u l e r _ p o l i c y _ g e t _ s c h e d u l e r ( s t r u c t s c h e d u l e r _ p o l i c y ∗ p o l i c y ) ;

    /∗ ∗∗ Get a r e f e r e n c e on t h e s c h e d u l e r owning a p r o c e s s s e t∗ The r e f e r e n c e must be p u t w i th s c h e d u l e r _ p u t ( )∗∗ @param p s e t p r o c e s s s e t o f t h e s e a r c h e d s c h e d u l e r∗∗ @return s c h e d u l e r owning t h e p r o c e s s s e t∗ /

    s t r u c t s c h e d u l e r ∗ p r o c e s s _ s e t _ g e t _ s c h e d u l e r ( s t r u c t p r o c e s s _ s e t ∗ p s e t ) ;

    /∗ ∗∗ Get a r e f e r e n c e on t h e sched p o l i c y o f a s c h e d u l e r∗ The r e f e r e n c e must be p u t w i th s c h e d u l e r _ p o l i c y _ p u t ( )∗∗ @param s c h e d u l e r s c h e d u l e r which sched p o l i c y t o g e t∗∗ @return sched p o l i c y o f t h e s c h e d u l e r∗ /

    s t r u c t s c h e d u l e r _ p o l i c y ∗s c h e d u l e r _ g e t _ s c h e d u l e r _ p o l i c y ( s t r u c t s c h e d u l e r ∗ s c h e d u l e r ) ;

    /∗ ∗∗ Get a r e f e r e n c e on t h e p r o c e s s s e t managed by a s c h e d u l e r∗ The r e f e r e n c e must be p u t w i th p r o c e s s _ s e t _ p u t ( )∗∗ @param s c h e d u l e r s c h e d u l e r t o g e t t h e p r o c e s s s e t o f∗∗ @return p r o c e s s s e t o f t h e s c h e d u l e r , o r∗ NULL i f t h e s c h e d u l e r i s n o t a c t i v e anymore

    18

  • D1.2 3.2 API for Component Programmers

    ∗ /s t r u c t p r o c e s s _ s e t ∗ s c h e d u l e r _ g e t _ p r o c e s s _ s e t ( s t r u c t s c h e d u l e r ∗ s c h e d u l e r ) ;

    /∗ ∗∗ Get t h e c u r r e n t node s e t o f t h e s c h e d u l e r∗∗ @param s c h e d u l e r s c h e d u l e r which node s e t t o g e t∗ @param n o d e _ s e t n o d e _ s e t t o copy t h e s c h e d u l e r ’ s node s e t i n∗ /

    void s c h e d u l e r _ g e t _ n o d e _ s e t ( s t r u c t s c h e d u l e r ∗ s c h e d u l e r ,k rgnodemask_ t ∗ n o d e _ s e t ) ;

    3.2.3 Policies

    The API for policy components can be found in kernel header .We provide here the public part of this header.

    s t r u c t t a s k _ s t r u c t ;

    /∗ ∗∗ Thi s s t r u c t u r e r e p r e s e n t s p l u g g a b l e s c h e d u l i n g p o l i c i e s f o r d i s t r i b u t i n g∗ l o a d i n t h e c l u s t e r based on d a t a measured by p r o b e s ( e . g . CPU usage , memory∗ usage , . . . ) . User can implement t h e s e s c h e d u l i n g p o l i c i e s a s s e p a r a t e Linux∗ k e r n e l modules and i n s e r t s them dynamca l ly i n t o k e r n e l . By do ing t h i s , i t∗ e x t e n d s s e t o f s c h e d u l i n g a l g o r i t h m s f o r d i s t r i b u t i n g l o a d a c r o s s t h e∗ c l u s t e r .∗ @author Marko Novak , Lou i s R i l l i n g∗ /

    s t r u c t s c h e d u l e r _ p o l i c y {s t r u c t c o n f i g _ g r o u p group ; /∗ ∗ r e p r e s e n t a t i o n o f s c h e d u l i n g p o l i c y i n

    ConfigFS . ∗ /s p i n l o c k _ t l o c k ; /∗ ∗ l o c k f o r s y n c h r o n i z i n g s c h e d u l i n g p o l i c y a c c e s s . ∗ /s t r u c t g l o b a l _ c o n f i g _ i t e m g l o b a l _ i t e m ; /∗ ∗ g l o b a l _ c o n f i g subsys t em ∗ /s t r u c t g l o b a l _ c o n f i g _ a t t r s g l o b a l _ a t t r s ;

    } ;

    /∗ ∗ s t r u c t which c o n t a i n s each p o l i c y ’ s o p e r a t i o n s . ∗ /s t r u c t s c h e d u l e r _ p o l i c y _ o p e r a t i o n s {

    s t r u c t s c h e d u l e r _ p o l i c y ∗ (∗ new ) ( c o n s t char ∗name ) ; /∗ sched p o l i c y∗ c o n s t r u c t o r ∗ /

    void (∗ d e s t r o y ) ( s t r u c t s c h e d u l e r _ p o l i c y ∗ p o l i c y ) ; /∗ sched p o l i c y∗ d e s t r u c t o r ∗ /

    /∗ n o t i f i e r o f node s e t changes ∗ /void (∗ u p d a t e _ n o d e _ s e t ) ( s t r u c t s c h e d u l e r _ p o l i c y ∗ p o l i c y ,

    c o n s t krgnodemask_ t ∗ new_set ,c o n s t krgnodemask_ t ∗ removed_se t ,c o n s t krgnodemask_ t ∗ a d d e d _ s e t ) ;

    /∗ p r o c e s s p l a c e m e n t f u n c t i o n∗ c a l l e d when a t a s k a t t a c h e d t o t h i s p o l i c y c r e a t e s a new t a s k ∗ /

    k e r r i g h e d _ n o d e _ t (∗ new_task_node ) ( s t r u c t s c h e d u l e r _ p o l i c y ∗ p o l i c y ,s t r u c t t a s k _ s t r u c t ∗ p a r e n t ) ;

    } ;

    /∗ Same l i m i t a t i o n as c o n f i g f s ( s e e SIMPLE_ATTR_SIZE i n f s / c o n f i g f s / f i l e . c ) ∗ /

    19

  • D1.2 3.2 API for Component Programmers

    # d e f i n e SCHEDULER_POLICY_ATTR_SIZE 4096

    /∗∗ Thi s s t r u c t i s used f o r r e p r e s e n t i n g s c h e d u l i n g p o l i c i e s ’ a t t r i b u t e s .∗ I t c o n t a i n s a t t r i b u t e −s p e c i f i c f u n c t i o n s f o r r e a d i n g and s t o r i n g a t t r i b u t e∗ v a l u e .∗ /

    s t r u c t s c h e d u l e r _ p o l i c y _ a t t r i b u t e {s t r u c t c o n f i g f s _ a t t r i b u t e a t t r ;

    /∗ ∗ f u n c t i o n f o r r e a d i n g a t t r i b u t e ’ s v a l u e ∗ /s s i z e _ t (∗ show ) ( s t r u c t s c h e d u l e r _ p o l i c y ∗ , char ∗ ) ;/∗ ∗ f u n c t i o n f o r s t o r i n g a t t r i b u t e ’ s v a l u e ∗ /s s i z e _ t (∗ s t o r e ) ( s t r u c t s c h e d u l e r _ p o l i c y ∗ , c o n s t char ∗ , s i z e _ t ) ;

    } ;

    /∗∗ To be i n i t i a l i z e d wi th SCHEDULER_POLICY_TYPE[ _INIT ] . The sched p o l i c y∗ subsys t em w i l l c o m p l e t e i n i t a t r e g i s t r a t i o n .∗ /

    s t r u c t s c h e d u l e r _ p o l i c y _ t y p e ;

    /∗ ∗∗ Mandatory macro t o d e f i n e a s c h e d u l i n g p o l i c y t y p e . Can be used t h r o u g h t h e∗ SCHEDULER_POLICY_TYPE macro .∗∗ @param owner Module d e f i n i n g t h e s c h e d u l e r _ p o l i c y t y p e∗ @param _name Unique name f o r t h e s c h e d u l e r _ p o l i c y t y p e∗ @param _ops s c h e d u l e r _ p o l i c y _ o p e r a t i o n s f o r t h i s t y p e∗ @param _ a t t r s NULL−t e r m i n a t e d a r r a y o f s c h e d u l e r _ p o l i c y _ a t t r i b u t e ,∗ or NULL∗ /

    # d e f i n e SCHEDULER_POLICY_TYPE_INIT ( owner , _name , _ops , _ a t t r s )

    /∗ ∗∗ Convenience macro t o d e f i n e a s c h e d u l i n g p o l i c y t y p e .∗∗ @param v a r Name of t h e v a r i a b l e c o n t a i n i n g t h e t y p e∗ @param name Unique name of t h e s c h e d u l e r _ p o l i c y t y p e∗ @param ops s c h e d u l e r _ p o l i c y _ o p e r a t i o n s f o r t h i s t y p e∗ @param a t t r s NULL−t e r m i n a t e d a r r a y o f s c h e d u l e r _ p o l i c y _ a t t r i b u t e ,∗ or NULL∗ /

    # d e f i n e SCHEDULER_POLICY_TYPE( var , name , ops , a t t r s )

    /∗ ∗∗ Thi s f u n c t i o n i n i t i a l i z e s a new s c h e d u l i n g p o l i c y . Must be c a l l e d by∗ s c h e d u l e r _ p o l i c y c o n s t r u c t o r s .∗ @author Marko Novak , Lou i s R i l l i n g∗∗ @param p o l i c y p o i n t e r t o t h e s c h e d u l e r _ p o l i c y t o i n i t∗ @param name name of t h e s c h e d u l i n g p o l i c y . Th i s name must be t h e one∗ p r o v i d e d as argument t o t h e c o n s t r u c t o r .∗ @param t y p e t y p e o f t h e s c h e d u l e r _ p o l i c y

    20

  • D1.2 3.2 API for Component Programmers

    ∗ @param d e f _ g r o u p s NULL−t e r m i n a t e d a r r a y o f s u b d i r s o f t h e s c h e d u l e r _ p o l i c y∗ d i r e c t o r y , o r NULL∗∗ @return 0 i f s u c c e s s u l ,∗ −ENODEV i s module i s u n l o a d i n g ( s h o u l d n o t happen ! ) ,∗ −ENOMEM i f n o t s u f f i c i e n t memory c o u l d be a l l o c a t e d .∗ /

    i n t s c h e d u l e r _ p o l i c y _ i n i t ( s t r u c t s c h e d u l e r _ p o l i c y ∗ p o l i c y ,c o n s t char ∗name ,s t r u c t s c h e d u l e r _ p o l i c y _ t y p e ∗ type ,s t r u c t c o n f i g _ g r o u p ∗ d e f _ g r o u p s [ ] ) ;

    /∗ ∗∗ Thi s f u n c t i o n f r e e s a l l t h e memory t a k e n by a s c h e d u l i n g p o l i c y . Must be∗ c a l l e d by t h e s c h e d u l e r _ p o l i c y d e s t r u c t o r .∗ @author Marko Novak , Lou i s R i l l i n g∗∗ @param p o l i c y p o i n t e r t o s c h e d u l e r _ p o l i c y whose memory we want t o f r e e∗ /

    void s c h e d u l e r _ p o l i c y _ c l e a n u p ( s t r u c t s c h e d u l e r _ p o l i c y ∗ p o l i c y ) ;

    /∗ ∗∗ Get a r e f e r e n c e on a sched p o l i c y∗∗ @param p o l i c y sched p o l i c y t o g e t a r e f e r e n c e on∗ /

    void s c h e d u l e r _ p o l i c y _ g e t ( s t r u c t s c h e d u l e r _ p o l i c y ∗ p o l i c y ) ;

    /∗ ∗∗ Put a r e f e r e n c e on a sched p o l i c y∗∗ @param p o l i c y sched p o l i c y which r e f e r e n c e t o p u t∗ /

    void s c h e d u l e r _ p o l i c y _ p u t ( s t r u c t s c h e d u l e r _ p o l i c y ∗ p o l i c y ) ;

    /∗ ∗∗ N o t i f y a p o l i c y t h a t i t s node s e t was u p d a t e d∗ C a l l e d wi th t h e s c h e d u l e r ’ s node s e t mutex l o c k e d .∗∗ @param p o l i c y p o l i c y t o n o t i f y∗ @param new_se t new node s e t o f t h e p o l i c y∗ @param removed_se t nodes j u s t removed from t h e s e t∗ @param a d d e d _ s e t nodes j u s t added t o t h e s e t∗ /

    void s c h e d u l e r _ p o l i c y _ u p d a t e _ n o d e _ s e t ( s t r u c t s c h e d u l e r _ p o l i c y ∗ p o l i c y ,c o n s t krgnodemask_ t ∗ new_set ,c o n s t krgnodemask_ t ∗ removed_se t ,c o n s t krgnodemask_ t ∗ a d d e d _ s e t ) ;

    /∗ ∗∗ Compute t h e b e s t node t o p l a c e a new t a s k c r e a t e d by p a r e n t a c c o r d i n g t o t h i s∗ s c h e d u l i n g p o l i c y∗ The new t a s k may n o t be c r e a t e d on t h e s e l e c t e d node a t a l l , s i n c e a n o t h e r∗ s c h e d u l i n g p o l i c y a t t a c h e d t o t h e same t a s k may d e c i d e d i f f e r e n t l y and win .

    21

  • D1.2 3.2 API for Component Programmers

    ∗∗ @author Marko Novak , Lou i s R i l l i n g∗∗ @param p o l i c y p o l i c y t h a t i s c o n s u l t e d∗ @param p a r e n t p a r e n t o f t h e t a s k t o be c r e a t e d∗ /

    k e r r i g h e d _ n o d e _ t s c h e d u l e r _ p o l i c y _ n e w _ t a s k _ n o d e ( s t r u c t s c h e d u l e r _ p o l i c y ∗ p o l i c y ,s t r u c t t a s k _ s t r u c t ∗ p a r e n t ) ;

    /∗ ∗∗ Thi s f u n c t i o n i s used f o r r e g i s t e r i n g newly added s c h e d u l i n g p o l i c y t y p e s .∗ Once a t y p e i s r e g i s t e r e d , new s c h e d u l i n g p o l i c i e s o f t h i s t y p e can be∗ c r e a t e d when u s e r does mkdir w i th t h e t y p e name .∗ @author Marko Novak , Lou i s R i l l i n g∗∗ @param t y p e p o i n t e r t o t h e s c h e d u l i n g p o l i c y t y p e t o r e g i s t e r .∗∗ @return 0 i f s u c c e s s f u l ,∗ −EEXIST i f s c h e d u l i n g p o l i c y t y p e wi th t h e same name∗ i s a l r e a d y r e g i s t e r e d .∗ /

    i n t s c h e d u l e r _ p o l i c y _ t y p e _ r e g i s t e r ( s t r u c t s c h e d u l e r _ p o l i c y _ t y p e ∗ t y p e ) ;

    /∗ ∗∗ Thi s f u n c t i o n i s used f o r removing s c h e d u l i n g p o l i c y r e g i s t r a t i o n s .∗ Must ∗ on ly ∗ be c a l l e d a t module u n l o a d i n g .∗ @author Marko Novak , Lou i s R i l l i n g∗∗ @param t y p e p o i n t e r t o t h e s c h e d u l i n g p o l i c y t y p e t o u n r e g i s t e r .∗ /

    void s c h e d u l e r _ p o l i c y _ t y p e _ u n r e g i s t e r ( s t r u c t s c h e d u l e r _ p o l i c y _ t y p e ∗ t y p e ) ;

    3.2.4 Ports

    The API for port components can be found in kernel header .We provide here the public part of this header.

    /∗∗ A s c h e d u l e r _ p o r t i s a s c h e d u l e r _ p i p e ha v i ng a t l e a s t a s c h e d u l e r _ s i n k . The∗ s i n k can c o n n e c t t o a n o t h e r s c h e d u l e r _ p i p e h av i ng a s o u r c e .∗∗ Doing mkdir i n a s c h e d u l e r _ p o r t d i r e c t o r y c r e a t e s a new s c h e d u l e r _ p o r t ha v in g∗ a sou rce , which t y p e i s named a f t e r t h e new s u b d i r name . The c r e a t o r p o r t ’ s∗ s i n k i s c o n n e c t e d t o t h e c r e a t e d p o r t ’ s s o u r c e .∗∗ C r e a t i n g a syml ink from an e n t r y o f p o r t ’ s d i r e c t o r y t o a n o t h e r∗ s c h e d u l e r _ p i p e d i r e c t o r y ( c u r r e n t l y t h i s i s on ly a l l o w e d f o r p robe s o u r c e s )∗ c o n n e c t s t h e p o r t ’ s s i n k t o t h e syml ink t a r g e t ’ s s o u r c e .∗∗ In bo th k ind of c o n n e c t i o n s , t h e c o n n e c t i o n i s p u b l i s h−s u b s c r i b e e n a b l e d i f∗ t h e p o r t p r o v i d e s an u p d a t e _ v a l u e ( ) method and e i t h e r has no s o u r c e o r∗ i t s s o u r c e a l r e a d y has s u b s c r i b e r s .∗ /

    22

  • D1.2 3.2 API for Component Programmers

    s t r u c t s c h e d u l e r _ p o r t ;s t r u c t s c h e d u l e r _ p o r t _ t y p e ;

    /∗ ∗∗ p r o t o t y p e f o r a p o r t c a l l b a c k t h a t g e t s t h e v a l u e o f a remote lower s o u r c e∗∗ @param p o r t p o r t f o r which t h e c a l l b a c k i s c a l l e d∗ @param node node t o g e t t h e v a l u e from∗ @param v a l u e _ p a r r a y o f v a l u e s t o be f i l l e d∗ @param nr max number o f v a l u e s t o f i l l∗ @param i n _ v a l u e _ p a r r a y o f p a r a m e t e r s , o r NULL∗ @param i n _ n r number o f e l e m e n t s i n i n _ v a l u e _ p∗∗ @return number o f v a l u e s f i l l e d , o r∗ −EAGAIN i f t h e r e q u e s t i s pend ing and t h e c a l l e r s h o u l d∗ r e t r y l a t e r , o r∗ o t h e r n e g a t i v e e r r o r code∗ /

    t y p e d e f i n t p o r t _ g e t _ r e m o t e _ v a l u e _ t ( s t r u c t s c h e d u l e r _ p o r t ∗ p o r t ,k e r r i g h e d _ n o d e _ t node ,void ∗ va lue_p , unsigned i n t nr ,c o n s t vo id ∗ i n _ v a l u e _ p ,unsigned i n t i n _ n r ) ;

    /∗ ∗∗ p r o t o t y p e f o r a p o r t t y p e c a l l b a c k t h a t c r e a t e s a new p o r t∗∗ @param name d i r e c t o r y name of t h e new p o r t∗∗ @return v a l i d p o i n t e r t o a new p o r t , o r∗ NULL i f no p o r t c o u l d be s u c c e s s f u l l y c r e a t e d∗ /

    t y p e d e f s t r u c t s c h e d u l e r _ p o r t ∗ p o r t _ n e w _ t ( c o n s t char ∗name ) ;

    /∗ ∗∗ p r o t o t y p e f o r a p o r t t y p e c a l l b a c k t h a t d e s t r o y s a p o r t ( f o r i n s t a n c e f r e e s∗ memory )∗∗ @param p o r t p o r t t o d e s t r o y∗ /

    t y p e d e f void p o r t _ d e s t r o y _ t ( s t r u c t s c h e d u l e r _ p o r t ∗ ) ;

    /∗∗ S t r u c t u r e r e p r e s e n t i n g a t y p e o f p o r t . Must be i n i t i a l i z e d wi th∗ SCHEDULER_PORT_TYPE_INIT ( f o r i n s t a n c e t h r o u g h BEGIN_SCHEDULER_PORT_TYPE and∗ SCHEDULER_PORT_∗ h e l p e r s ) .∗ /

    s t r u c t s c h e d u l e r _ p o r t _ t y p e {c o n s t char ∗name ;s t r u c t s c h e d u l e r _ s i n k _ t y p e s i n k _ t y p e ;s t r u c t s c h e d u l e r _ p i p e _ t y p e p i p e _ t y p e ;/∗ method t o g e t t h e v a l u e from a remote node ∗ /p o r t _ g e t _ r e m o t e _ v a l u e _ t ∗ g e t _ r e m o t e _ v a l u e ;

    23

  • D1.2 3.2 API for Component Programmers

    /∗ ∗ c o n s t r u c t o r o f p o r t s o f t h i s t y p e ∗ /p o r t _ n e w _ t ∗new ;/∗ ∗ d e s t r u c t o r o f p o r t s o f t h i s t y p e ∗ /p o r t _ d e s t r o y _ t ∗ d e s t r o y ;s t r u c t l i s t _ h e a d l i s t ;

    } ;

    /∗ S t r u c t u r e r e p r e s e n t i n g a p o r t ∗ /s t r u c t s c h e d u l e r _ p o r t ;

    s t r u c t s c h e d u l e r _ p o r t _ a t t r i b u t e ;

    /∗ Same l i m i t a t i o n as c o n f i g f s ( s e e SIMPLE_ATTR_SIZE i n f s / c o n f i g f s / f i l e . c ) ∗ /# d e f i n e SCHEDULER_PORT_ATTR_SIZE 4096

    /∗ ∗∗ p r o t o t y p e f o r a p o r t _ a t t r i b u t e c a l l b a c k t h a t r e a d s a p o r t a t t r i b u t e∗∗ @param p o r t p o r t which a t t r i b u t e i s r e a d∗ @param a t t r s t r u c t u r e d e s c r i b i n g t h e a t t r i b u t e r e a d∗ @param page 4 Kbytes b u f f e r t o f i l l i n∗∗ @return number o f b y t e s w r i t t e n t o page , o r∗ n e g a t i v e e r r o r code∗ /

    t y p e d e f s s i z e _ t p o r t _ a t t r i b u t e _ s h o w _ t ( s t r u c t s c h e d u l e r _ p o r t ∗ p o r t ,s t r u c t s c h e d u l e r _ p o r t _ a t t r i b u t e ∗ a t t r ,char ∗ page ) ;

    /∗ ∗∗ p r o t o t y p e f o r a p o r t _ a t t r i b u t e c a l l b a c k t h a t m o d i f i e s a p o r t a t t r i b u t e∗∗ @param p o r t p o r t which a t t r i b u t e i s r e a d∗ @param a t t r s t r u c t u r e d e s c r i b i n g t h e a t t r i b u t e r e a d∗ @param b u f f e r b u f f e r c o n t a i n i n g t h e d a t a t o modify a t t r∗ @param c o u n t s i z e i n b y t e s o f t h e m o d i f i c a t i o n d a t a∗∗ @return number o f b y t e s r e a d from b u f f e r , o r∗ n e g a t i v e e r r o r code∗ /

    t y p e d e f s s i z e _ t p o r t _ a t t r i b u t e _ s t o r e _ t ( s t r u c t s c h e d u l e r _ p o r t ∗ p o r t ,s t r u c t s c h e d u l e r _ p o r t _ a t t r i b u t e ∗ a t t r ,c o n s t char ∗ b u f f e r , s i z e _ t c o u n t ) ;

    /∗∗ S t r u c t u r e r e p r e s e n t i n g a s c h e d u l e r _ p o r t a t t r i b u t e . Must be i n i t i a l i z e d wi th∗ SCHEDULER_PORT_ATTRIBUTE_INIT .∗ /

    s t r u c t s c h e d u l e r _ p o r t _ a t t r i b u t e {s t r u c t c o n f i g f s _ a t t r i b u t e c o n f i g ;/∗ ∗ method t o r e a d a custom a t t r i b u t e o f a p o r t o f t h i s t y p e ∗ /p o r t _ a t t r i b u t e _ s h o w _ t ∗show ;/∗ ∗ method t o modify a custom a t t r i b u t e o f a p o r t o f t h i s t y p e ∗ /p o r t _ a t t r i b u t e _ s t o r e _ t ∗ s t o r e ;

    } ;

    24

  • D1.2 3.2 API for Component Programmers

    /∗ ∗∗ Mandatory macro t o d e f i n e a s c h e d u l e r _ p o r t _ t y p e . Can be c a l l e d t h r o u g h∗ t h e BEGIN_SCHEDULER_PORT_TYPE h e l p e r .∗∗ @param p o r t _ t y p e v a r i a b l e name of t h e p o r t t y p e∗ @param owner module p r o v i d i n g t h i s p o r t t y p e∗ @param _name s t r i n g c o n t a i n i n g t h e u n iq ue name of t h i s p o r t t y p e∗ @param s n k _ u p d a t e _ v a l u e∗ method t o g i v e t o t h e s c h e d u l e r _ s i n k of a∗ p o r t o f t h i s t y p e∗ @param s n k _ v a l u e _ t y p e∗ s t r i n g c o n t a i n i n g t h e t y p e name of lower s o u r c e ’ s v a l u e s∗ @param s n k _ v a l u e _ t y p e _ s i z e∗ s i z e i n b y t e s o f a s n k _ v a l u e _ t y p e v a l u e∗ @param s n k _ g e t _ p a r a m _ t y p e∗ s t r i n g c o n t a i n i n g t h e t y p e name of t h e p a r a m e t e r s f o r∗ t h e s i n k ’ s g e t _ v a l u e ( ) c a l l s , o r NULL∗ @param s n k _ g e t _ p a r a m _ t y p e _ s i z e∗ s i z e i n b y t e s o f a s n k _ g e t _ p a r a m _ t y p e p a r a m e t e r∗ @param s o u r c e _ t y p e o p t i o n a l s o u r c e t y p e t o a t t a c h t o t h e∗ s c h e d u l e r _ p i p e _ t y p e o f t h i s p o r t t y p e∗ @param _ g e t _ r e m o t e _ v a l u e∗ g e t _ r e m o t e _ v a l u e ( ) method of t h i s p o r t t y p e∗ @param _new c r e a t o r o f p o r t s o f t h i s t y p e∗ @param _ d e s t r o y d e s t r u c t o r s o f p o r t s o f t h i s t y p e∗ /

    # d e f i n e SCHEDULER_PORT_TYPE_INIT ( p o r t _ t y p e , owner , _name ,s n k _ u p d a t e _ v a l u e ,s n k _ v a l u e _ t y p e , s n k _ v a l u e _ t y p e _ s i z e ,snk_ge t_pa ram_type , s n k _ g e t _ p a r a m _ t y p e _ s i z e ,s o u r c e _ t y p e ,_ g e t _ r e m o t e _ v a l u e ,_new ,_ d e s t r o y )

    /∗∗ Convenience macros t o d e f i n e a s c h e d u l e r _ p o r t _ t y p e∗∗ These c o n v e n i e n c e macros s h o u l d be used t h e f o l l o w i n g way :∗∗ F i r s t , implemented methods must be d e f i n e d u s i n g t h e∗ DEFINE_SCHEDULER_PORT_ macros . Second , t h e s c h e d u l e r _ p o r t _ t y p e must∗ be f i l l e d u s i n g {BEGIN ,END}_SCHEDULER_PORT_TYPE and SCHEDULER_PORT_∗ macros :∗∗ BEGIN_SCHEDULER_PORT_TYPE( name ) ,∗ . SCHEDULER_PORT_VALUE_TYPE( name , t y p e ) ,∗ i f needed :∗ . SCHEDULER_PORT_( name ) ,∗ . SCHEDULER_PORT_PARAM_TYPE( name , t y p e ) ,∗ . SCHEDULER_PORT_ATTRS( name , a t t r s ) ,∗ . . .∗ and f i n a l l y :∗ END_SCHEDULER_PORT_TYPE( name ) ;

    25

  • D1.2 3.2 API for Component Programmers

    ∗ /

    /∗ ∗∗ Convenience macro t o s t a r t t h e d e f i n i t i o n o f a s c h e d u l e r _ p o r t _ t y p e . The∗ d e f i n i t i o n must end wi th END_SCHEDULER_PORT_TYPE( name ) . The v a r i a b l e w i l l be∗ c a l l e d name_type .∗∗ @param name name of t h e s c h e d u l e r _ p o r t t y p e∗ /

    # d e f i n e BEGIN_SCHEDULER_PORT_TYPE( _name )

    /∗ ∗∗ Convenience macro t o a t t a c h a p r e v i o u s l y d e f i n e d u p d a t e _ v a l u e ( ) method t o a∗ s c h e d u l e r _ p o r t t y p e . The u p d a t e _ v a l u e ( ) method must have been d e f i n e d e a r l i e r∗ wi th DEFINE_SCHEDULER_PORT_UPDATE_VALUE( name , . . . ) .∗∗ @param name must match t h e name used wi th BEGIN_SCHEDULER_PORT_TYPE∗ /

    # d e f i n e SCHEDULER_PORT_UPDATE_VALUE( name )

    /∗ ∗∗ Convenience macro t o d e c l a r e t h e v a l u e t y p e o f a s c h e d u l e r p o r t . Must be used∗ w i t h i n a l l BEGIN_SCHEDULER_PORT_TYPE s e c t i o n s .∗∗ @param name must match t h e name used wi th BEGIN_SCHEDULER_PORT_TYPE∗ @param t y p e l i t t e r a l e x p r e s s i o n o f t h e v a l u e t y p e r e a d by t h e s i n k∗ /

    # d e f i n e SCHEDULER_PORT_VALUE_TYPE( name , t y p e )

    /∗ ∗∗ Convenience macro t o d e c l a r e t h e p a r a m e t e r t y p e used when c a l l i n g t h e∗ g e t _ v a l u e ( ) method of a c o n n e c t e d s o u r c e .∗∗ @param name must match t h e name used wi th BEGIN_SCHEDULER_PORT_TYPE∗ @param t y p e l i t t e r a l e x p r e s s i o n o f t h e p a r a m e t e r t y p e∗ /

    # d e f i n e SCHEDULER_PORT_PARAM_TYPE( name , t y p e )

    /∗ ∗∗ Convenience macro t o a t t a c h a s o u r c e t y p e t o t h e p i p e _ t y p e embedded i n a∗ s c h e d u l e r _ p o r t _ t y p e∗∗ @param name must match t h e name used wi th BEGIN_SCHEDULER_PORT_TYPE∗ @param s o u r c e _ t y p e s o u r c e _ t y p e t o a t t a c h∗ /

    # d e f i n e SCHEDULER_PORT_SOURCE_TYPE( name , s o u r c e _ t y p e )

    /∗ ∗∗ Convenience macro t o a t t a c h a p r e v i o u s l y d e f i n e d g e t _ r e m t e _ v a l u e ( ) method t o∗ a s c h e d u l e r _ p o r t t y p e . The g e t _ r e m o t e _ v a l u e ( ) method must have been d e f i n e d∗ e a r l i e r w i th DEFINE_SCHEDULER_PORT_GET_REMOTE_VALUE( name , . . . ) .∗∗ @param name must match t h e name used wi th BEGIN_SCHEDULER_PORT_TYPE∗ /

    26

  • D1.2 3.2 API for Component Programmers

    # d e f i n e SCHEDULER_PORT_GET_REMOTE_VALUE( name )

    /∗ ∗∗ Convenience macro t o a t t a c h a p r e v i o u s l y d e f i n e d c o n s t r u c t o r t o a p o r t t y p e .∗ The c o n s t r u c t o r must have been d e f i n e d e a r l i e r and must be c a l l e d name_new .∗∗ @param name must match t h e name used wi th BEGIN_SCHEDULER_PORT_TYPE∗ /

    # d e f i n e SCHEDULER_PORT_NEW( name )

    /∗ ∗∗ Convenience macro t o a t t a c h a p r e v i o u s l y d e f i n e d d e s t r u c t o r t o a p o r t t y p e .∗ The d e s t r u c t o r must have been d e f i n e d e a r l i e r and must be c a l l e d∗ name_des t roy .∗∗ @param name must match t h e name used wi th BEGIN_SCHEDULER_PORT_TYPE∗ /

    # d e f i n e SCHEDULER_PORT_DESTROY( name )

    /∗ ∗∗ End t h e d e f i n i t i o n o f a s c h e d u l e r _ p o r t _ t y p e . Must c l o s e any∗ BEGIN_SCHEDULER_PORT_TYPE s e c t i o n .∗∗ @param name must match t h e name used wi th BEGIN_SCHEDULER_PORT_TYPE∗ /

    # d e f i n e END_SCHEDULER_PORT_TYPE( name )

    /∗ ∗∗ Convenience macro t o d e f i n e an u p d a t e _ v a l u e ( ) method f o r a p o r t .∗ The method w i l l be c a l l e d name_upda t e_va lue .∗∗ @param name name of t h e s c h e d u l e r _ p o r t t y p e∗ @param p o r t name of t h e p o r t a r g o f t h e method∗ /

    # d e f i n e DEFINE_SCHEDULER_PORT_UPDATE_VALUE( name , p o r t )

    /∗ ∗∗ Convenience macro t o d e f i n e an g e t _ r e m o t e _ v a l u e ( ) method f o r a p o r t , w i t h o u t∗ p a r a m e t e r s g i v e n t o t h e s o u r c e . The method w i l l be c a l l e d∗ n a m e _g e t _ r e mo t e _ v a l ue .∗∗ @param name name of t h e s c h e d u l e r _ p o r t t y p e∗ @param p o r t name of t h e p o r t a r g o f t h e method∗ @param v a l u e _ t y p e t y p e o f t h e v a l u e s r e a d by t h e s i n k ( eg . i n t )∗ @param v a l u e _ p name of t h e t y p e ∗ a r g o f t h e method∗ @param n r _ v a l u e name of t h e a r r a y l e n g t h p a r a m e t e r o f t h e method∗ /

    # d e f i n e DEFINE_SCHEDULER_PORT_GET_REMOTE_VALUE( name , p o r t ,v a l u e _ t y p e , va lue_p , n r _ v a l u e )

    /∗ ∗∗ Convenience macro t o d e f i n e an g e t _ r e m o t e _ v a l u e ( ) method f o r a p o r t , w i th∗ p a r a m e t e r s g i v e n t o t h e s o u r c e . The method w i l l be c a l l e d∗ n a m e _g e t _ r e mo t e _ v a l ue .

    27

  • D1.2 3.2 API for Component Programmers

    ∗∗ @param name name of t h e s c h e d u l e r _ p o r t t y p e∗ @param p o r t name of t h e p o r t a r g o f t h e method∗ @param v a l u e _ t y p e t y p e o f t h e v a l u e s r e a d by t h e s i n k ( eg . i n t )∗ @param v a l u e _ p name of t h e t y p e ∗ a r g o f t h e method∗ @param n r _ v a l u e name of t h e a r r a y l e n g t h p a r a m e t e r o f t h e method∗ @param param_type t y p e o f t h e p a r a m e t e r s g i v e n t o t h e s o u r c e ( eg . i n t )∗ @param param_p name of t h e param_type ∗ a r g o f t h e method∗ @param nr_param name of t h e p a r a m e t e r s a r r a y l e n g t h a r g o f t h e method∗ /

    # d e f i n e DEFINE_SCHEDULER_PORT_GET_REMOTE_VALUE_WITH_INPUT(name , p o r t ,v a l u e _ t y p e , va lue_p , n r _ v a l u e ,param_type , param_p , nr_param )

    /∗ End of c o n v e n i e n c e macros ∗ /

    /∗ ∗∗ Mandatory i n i t i a l i z e r f o r a s c h e d u l e r _ p o r t _ a t t r i b u t e .∗∗ @param name name of t h e a t t r i b u t e e n t r y i n t h e p o r t d i r e c t o r y∗ @param mode a c c e s s mode of t h e a t t r i b u t e e n t r y∗ @param _show show c a l l b a c k of t h e a t t r i b u t e∗ @param _ s t o r e s t o r e c a l l b a c k of t h e a t t r i b u t e∗ /

    # d e f i n e SCHEDULER_PORT_ATTRIBUTE_INIT ( name , mode , _show , _ s t o r e )

    /∗ Tool f u n c t i o n s f o r p o r t d e s i g n e r s ∗ /

    /∗ ∗∗ I n i t i a l i z e a s c h e d u l e r p o r t t y p e∗ Must be c a l l e d b e f o r e c r e a t i n g any p o r t o f t h i s t y p e . I s c a l l e d t h r o u g h∗ s c h e d u l e r _ p o r t _ t y p e _ r e g i s t e r ( ) .∗∗ @param t y p e t y p e t o i n i t∗ @param a t t r s NULL−t e r m i n a t e d a r r a y o f p o i n t e r s t o custom a t t r i b u t e s ,∗ or NULL∗∗ @return 0 i s s u c c e s s f u l , o r∗ −ENOMEM i f no s u f f i c i e n t memory c o u l d be a l l o c a t e d∗ /

    i n t s c h e d u l e r _ p o r t _ t y p e _ i n i t ( s t r u c t s c h e d u l e r _ p o r t _ t y p e ∗ type ,s t r u c t c o n f i g f s _ a t t r i b u t e ∗∗ a t t r s ) ;

    /∗ ∗∗ Free t h e r e s o u r c e s a l l o c a t e d a t t y p e i n i t i a l i z a t i o n∗∗ @param t y p e t y p e t o c l e a n u p∗ /

    void s c h e d u l e r _ p o r t _ t y p e _ c l e a n u p ( s t r u c t s c h e d u l e r _ p o r t _ t y p e ∗ t y p e ) ;

    /∗ ∗∗ I n i t i a l i z e and r e g i s t e r a new p o r t t y p e∗∗ @param t y p e t y p e t o r e g i s t e r

    28

  • D1.2 3.2 API for Component Programmers

    ∗ @param a t t r s NULL−t e r m i n a t e d a r r a y o f custom c o n f i g f s _ a t t r i b u t e , o r∗ NULL∗∗ @return 0 i f s u c c e s s f u l ,∗ −ENOMEM i f n o t s u f f i c i e n t memory c o u l d be a l l o c a t e d ,∗ −EEXIST i f a t y p e o f t h i s name i s a l r e a d y r e g i s t e r e d .∗ /

    i n t s c h e d u l e r _ p o r t _ t y p e _ r e g i s t e r ( s t r u c t s c h e d u l e r _ p o r t _ t y p e ∗ type ,s t r u c t c o n f i g f s _ a t t r i b u t e ∗∗ a t t r s ) ;

    /∗ ∗∗ U n r e g i s t e r and c l e a n u p a p o r t t y p e . Must be c a l l e d a t module u n lo ad ∗ on ly ∗ .∗∗ @param t y p e t y p e t o u n r e g i s t e r∗ /

    void s c h e d u l e r _ p o r t _ t y p e _ u n r e g i s t e r ( s t r u c t s c h e d u l e r _ p o r t _ t y p e ∗ t y p e ) ;

    /∗ ∗∗ I n i t i a l i z e a new s c h e d u l e r _ p o r t . Must be c a l l e d by s c h e d u l e r _ p o r t∗ c o n s t r u c t o r s .∗∗ @param p o r t p o r t t o i n i t i a l i z e∗ @param name name of t h e d i r e c t o r y o f t h i s p o r t . Must match t h e name∗ g i v e n as argument t o t h e c o n s t r u c t o r .∗ @param t y p e t y p e o f t h e new p o r t∗ @param s o u r c e o p t i o n a l s o u r c e o f t h e o b j e c t embedding p o r t , o r NULL∗ @param d e f a u l t _ g r o u p s∗ NULL t e r m i n a t e d a r r a y o f custom c o n f i g _ g r o u p s d i s p l a y e d∗ as s u b d i r s o f t h e p o r t , o r NULL∗∗ @return 0 i f s u c c e s s f u l ,∗ n e g a t i v e e r r o r code i f e r r o r∗ /

    i n t s c h e d u l e r _ p o r t _ i n i t ( s t r u c t s c h e d u l e r _ p o r t ∗ p o r t ,c o n s t char ∗name ,s t r u c t s c h e d u l e r _ p o r t _ t y p e ∗ type ,s t r u c t s c h e d u l e r _ s o u r c e ∗ sou rce ,s t r u c t c o n f i g _ g r o u p ∗∗ d e f a u l t _ g r o u p s ) ;

    /∗ ∗∗ Cleanup a s c h e d u l e r _ p o r t b e f o r e f r e e i n g i t . Must be c a l l e d by t h e p o r t ’ s∗ d e s t r u c t o r .∗∗ @param p o r t p o r t t o c l e a n u p∗ /

    void s c h e d u l e r _ p o r t _ c l e a n u p ( s t r u c t s c h e d u l e r _ p o r t ∗ p o r t ) ;

    /∗ ∗∗ H el pe r t o r e f e r t o a p o r t t h r o u g h i t s embedded c o n f i g _ g r o u p ( f o r i n s t a n c e∗ t o b u i l d t h e d e f a u l t _ g r o u p s [ ] a r r a y o f a p a r e n t c o n f i g _ g r o u p )∗∗ @param p o r t p o r t which c o n f i g _ g r o u p a d d r e s s t o r e t u r n∗∗ @return a d d r e s s o f t h e embedded c o n f i g _ g r o u p of t h e p o r t∗ /

    s t r u c t c o n f i g _ g r o u p ∗ s c h e d u l e r _ p o r t _ c o n f i g _ g r o u p ( s t r u c t s c h e d u l e r _ p o r t ∗ p o r t ) ;

    29

  • D1.2 3.2 API for Component Programmers

    /∗ F u n c t i o n s t o que ry a p o r t ∗ /

    /∗ ∗∗ Get t h e v a l u e from t h e s o u r c e c o n n e c t e d t o a p o r t∗∗ @param p o r t p o r t t o que ry∗ @param v a l u e _ p a r r a y o f v a l u e s t o be f i l l e d∗ @param nr max number o f v a l u e s t o f i l l∗ @param i n _ v a l u e _ p a r r a y o f p a r a m e t e r s , o r NULL∗ @param i n _ n r number o f e l e m e n t s i n i n _ v a l u e _ p∗∗ @return number o f v a l u e s f i l l e d , o r∗ n e g a t i v e e r r o r code∗ /

    i n t s c h e d u l e r _ p o r t _ g e t _ v a l u e ( s t r u c t s c h e d u l e r _ p o r t ∗ p o r t ,void ∗ va lue_p , unsigned i n t nr ,c o n s t vo id ∗ i n _ v a l u e _ p , unsigned i n t i n _ n r ) ;

    /∗ ∗∗ Show t h e v a l u e c o l l e c t e d by a p o r t ( from a i t s c o n n e c t e d s o u r c e ) a s a s t r i n g∗ ( f o r i n s t a n c e t h r o u g h c o n f i g f s )∗∗ @param p o r t p o r t t o que ry∗ @param page b u f f e r t o s t o r e t h e v a l u e (4 Kbytes s i z e )∗∗ @return number o f b y t e s w r i t t e n t o b u f f e r , o r∗ n e g a t i v e e r r o r code∗ /

    s s i z e _ t s c h e d u l e r _ p o r t _ s h o w _ v a l u e ( s t r u c t s c h e d u l e r _ p o r t ∗ p o r t , char ∗ page ) ;

    /∗ ∗∗ Get t h e v a l u e from t h e remote p e e r s o u r c e o f t h e s o u r c e c o n n e c t e d t o a p o r t .∗ I f t h e c o n n e c t e d s o u r c e i s i t s e l f a p o r t and d e f i n e s a g e t _ r e m o t e _ v a l u e ( )∗ method , i t s g e t _ r e m o t e _ v a l u e ( ) method w i l l be c a l l e d i n s t e a d . I f n o t∗ g e t _ r e m o t e _ v a l u e ( ) method i s d e f i n e d , t h e c a l l w i l l be f o r w a r d e d down u n t i l∗ e i t h e r a s o u r c e b e i n g n o t a p o r t i s found or a g e t _ r e m o t e _ v a l u e ( ) method i s∗ d e f i n e d .∗∗ See t h e d e f i n i t i o n o f p o r t _ g e t _ r e m o t e _ v a l u e _ t f o r t h e d e s c r i p t i o n s o f∗ p a r a m e t e r s and r e t u r n v a l u e .∗ /

    e x t er n p o r t _ g e t _ r e m o t e _ v a l u e _ t s c h e d u l e r _ p o r t _ g e t _ r e m o t e _ v a l u e ;

    3.2.5 Filters

    The API for filter components can be found in kernel header .We provide here the public part of this header.

    /∗∗ A f i l t e r i s a s c h e d u l e r _ p o r t ha v in g a s o u r c e . A f i l t e r c o l l e c t s d a t a / e v e n t s∗ from a s o u r c e c o n n e c t e d t o i t s s ink , and g e n e r a t e s d a t a / e v e n t s r e l a t e d t o∗ what i t c o l l e c t s . F i l t e r s s o u r c e s a r e c o n n e c t e d t o s c h e d u l e r _ p o r t s when do ing∗ mkdir i n p o r t s d i r e c t o r i e s , and f i l t e r s s i n k s a r e c o n n e c t e d t o lower s o u r c e s

    30

  • D1.2 3.2 API for Component Programmers

    ∗ t h e same way as p o r t s .∗∗ A f i l t e r can b l o c k u p d a t e p r o p a g a t i o n as w e l l g e n e r a t i n g u p d a t e s .∗∗ A f i l t e r can modify t h e v a l u e o f t h e s o u r c e i t i s c o n n e c t e d t o when t h e s i n k∗ i t i s c o n n e c t e d t o r e q u e s t s i t s va lue , a s w e l l a s p r o v i d i n g v a l u e s g e n e r a t e d∗ by o t h e r means .∗ /

    /∗ S t r u c t u r e r e p r e s e n t i n g a f i l t e r ∗ /s t r u c t s c h e d u l e r _ f i l t e r ;

    # d e f i n e SCHEDULER_FILTER_ATTR_SIZE SCHEDULER_PORT_ATTR_SIZE

    /∗∗ S t r u c t u r e r e p r e s e n t i n g a f i l t e r a t t r i b u t e∗ J u s t an API t r a n s l a t i o n from p o r t a t t r i b u t e s∗ /

    s t r u c t s c h e d u l e r _ f i l t e r _ a t t r i b u t e ;

    /∗∗ Convenience macros t o d e f i n e a s c h e d u l e r _ f i l t e r _ a t t r i b u t e∗∗ These c o n v e n i e n c e macros s h o u l d be used t h e f o l l o w i n g way :∗∗ F i r s t , implemented methods must be d e f i n e d u s i n g t h e∗ DEFINE_SCHEDULER_FILTER_ATTRIBUTE_ macros . Second , t h e∗ s c h e d u l e r _ f i l t e r _ a t t r i b u t e must be f i l l e d u s i n g∗ {BEGIN ,END}_SCHEDULER_FILTER_ATTRIBUTE and SCHEDULER_FILTER_ATTRIBUTE_∗∗ macros :∗∗ BEGIN_SCHEDULER_FILTER_ATTRIBUTE ( var_name , name , mode ) ,∗ i f needed :∗ . SCHEDULER_FILTER_ATTRIBUTE_( name ) ,∗ . . .∗ and f i n a l l y :∗ END_SCHEDULER_FILTER_ATTRIBUTE( name ) ;∗ /

    /∗ ∗∗ Convenience macro t o s t a r t t h e d e f i n i t i o n o f a∗ s c h e d u l e r _ f i l t e r _ a t t r i b u t e . The d e f i n i t i o n must end wi th∗ END_SCHEDULER_FILTER_ATTRIBUTE( name ) .∗∗ @param var_name name of t h e s c h e d u l e r _ f i l t e r _ a t t r i b u t e v a r i a b l e∗ @param name name of t h e a t t r i b u t e e n t r y i n t h e f i l t e r d i r e c t o r y∗ @param mode a c c e s s mode of t h e a t t r i b u t e e n t r y∗ /

    # d e f i n e BEGIN_SCHEDULER_FILTER_ATTRIBUTE ( var_name , name , mode )

    /∗ ∗∗ Convenience macro t o a t t a c h a p r e v i o u s l y d e f i n e d show ( ) method t o a∗ s c h e d u l e r _ f i l t e r _ a t t r i b u t e . The show ( ) method must have been d e f i n e d e a r l i e r∗ wi th DEFINE_SCHEDULER_FILTER_ATTRIBUTE_SHOW( name , . . . ) .

    31

  • D1.2 3.2 API for Component Programmers

    ∗∗ @param name must match t h e name used wi th∗ BEGIN_SCHEDULER_FILTER_ATTRIBUTE∗ /

    # d e f i n e SCHEDULER_FILTER_ATTRIBUTE_SHOW( name )

    /∗ ∗∗ Convenience macro t o a t t a c h a p r e v i o u s l y d e f i n e d s t o r e ( ) method t o a∗ s c h e d u l e r _ f i l t e r _ a t t r i b u t e . The s t o r e ( ) method must have been d e f i n e d e a r l i e r∗ wi th DEFINE_SCHEDULER_FILTER_ATTRIBUTE_STORE ( name , . . . ) .∗∗ @param name must match t h e name used wi th∗ BEGIN_SCHEDULER_FILTER_ATTRIBUTE∗ /

    # d e f i n e SCHEDULER_FILTER_ATTRIBUTE_STORE( name )

    /∗ ∗∗ End t h e d e f i n i t i o n o f a s c h e d u l e r _ f i l t e r _ a t t r i b u t e . Must c l o s e any∗ BEGIN_SCHEDULER_FILTER_ATTRIBUTE s e c t i o n .∗∗ @param name must match t h e name used wi th∗ BEGIN_SCHEDULER_FILTER_ATTRIBUTE∗ /

    # d e f i n e END_SCHEDULER_FILTER_ATTRIBUTE( name )

    /∗ ∗∗ Convenience macro t o d e f i n e an show ( ) method f o r a f i l t e r a t t r i b u t e . The∗ method w i l l be c a l l e d name_show .∗∗ @param name name of t h e f i l t e r a t t r i b u t e∗ @param f i l t e r f i l t e r which a t t r i b u t e i s r e a d∗ @param a t t r s c h e d u l e r _ f i l t e r _ a t t r i b u t e d e s c r i b i n g t h e a t t r i b u t e∗ @param page 4 Kbytes b u f f e r t o f i l l i n∗ /

    # d e f i n e DEFINE_SCHEDULER_FILTER_ATTRIBUTE_SHOW( name , f i l t e r , a t t r , page )

    /∗ ∗∗ Convenience macro t o d e f i n e an s t o r e ( ) method f o r a f i l t e r a t t r i b u t e . The∗ method w i l l be c a l l e d n a m e _ s t o r e .∗∗ @param name name of t h e f i l t e r a t t r i b u t e∗ @param f i l t e r f i l t e r which a t t r i b u t e i s t o be m o d i f i e d∗ @param a t t r s c h e d u l e r _ f i l t e r _ a t t r i b u t e d e s c r i b i n g t h e a t t r i b u t e∗ @param page b u f f e r c o n t a i n i n g t h e d a t a t o modify a t t r i b u t e∗ @param c o u n t number o f b y t e s c o n t a i n e d i n b u f f e r∗ /

    # d e f i n e DEFINE_SCHEDULER_FILTER_ATTRIBUTE_STORE ( name , f i l t e r , a t t r ,page , c o u n t )

    /∗ End of c o n v e n i e n c e macros ∗ /

    /∗∗ S t r u c t u r e d e s c r i b i n g a t y p e o f f i l t e r . F i l t e r o f t h i s t y p e can be c r e a t e d∗ once t h e t y p e i s r e g i s t e r e d .

    32

  • D1.2 3.2 API for Component Programmers

    ∗ /s t r u c t s c h e d u l e r _ f i l t e r _ t y p e ;

    /∗ ∗∗ Mandatory macro t o d e f i n e a s c h e d u l e r _ f i l t e r _ t y p e . Can be used t h r o u g h t h e∗ BEGIN_SCHEDULER_FILTER_TYPE h e l p e r .∗∗ @param f i l t e r _ t y p e v a r i a b l e name of t h e f i l t e r t y p e∗ @param owner module p r o v i d i n g t h i s t y p e∗ @param name un iq ue name among s c h e d u l e r _ p o r t _ t y p e names∗ @param new p o r t _ t y p e c o n s t r u c t o r f o r t h i s f i l t e r t y p e∗ @param d e s t r o y p o r t _ t y p e d e s t r u c t o r f o r t h i s f i l t e r t y p e∗ @param g e t _ v a l u e ( s o u r c e ) c a l l b a c k t o g e t t h e f i l t e r e d v a l u e∗ @param u p d a t e _ v a l u e ( s i n k ) c a l l b a c k c a l l e d when t h e s o u r c e o f a f i l t e r o f∗ t h i s t y p e n o t i f i e s an u p d a t e∗ @param show_value ( s o u r c e ) c a l l b a c k t o show t h e v a l u e f i l t e r e d by a f i l t e r∗ of t h i s t y p e∗ @param g e t _ r e m o t e _ v a l u e∗ ( p o r t ) c a l l b a c k t o g e t a remote f i l t e r e d v a l u e∗ @param s r c _ v a l u e _ t y p e∗ s t r i n g c o n t a i n i n g t h e t y p e name of f i l t e r ’ s v a l u e s∗ @param s r c _ v a l u e _ t y p e _ s i z e∗ s i z e i n b y t e s o f a s r c _ v a l u e _ t y p e v a l u e∗ @param s r c _ g e t _ p a r a m _ t y p e∗ s t r i n g c o n t a i n i n g t h e t y p e name of t h e p a r a m e t e r s f o r∗ t h e f i l t e r ’ s g e t _ v a l u e method , o r NULL∗ @param s r c _ g e t _ p a r a m _ t y p e _ s i z e∗ s i z e i n b y t e s o f a s r c _ g e t _ p a r a m _ t y p e p a r a m e t e r∗ @param s n k _ v a l u e _ t y p e∗ s t r i n g c o n t a i n i n g t h e t y p e name of lower s o u r c e ’ s v a l u e s∗ @param s n k _ v a l u e _ t y p e _ s i z e∗ s i z e i n b y t e s o f a s n k _ v a l u e _ t y p e v a l u e∗ @param s n k _ g e t _ p a r a m _ t y p e∗ s t r i n g c o n t a i n i n g t h e t y p e name of t h e p a r a m e t e r s f o r∗ t h e s i n k ’ s g e t _ v a l u e c a l l s , o r NULL∗ @param s n k _ g e t _ p a r a m _ t y p e _ s i z e∗ s i z e i n b y t e s o f a s n k _ g e t _ p a r a m _ t y p e p a r a m e t e r∗ @param _ a t t r s NULL−t e r m i n a t e d a r r a y o f custom∗ s c h e d u l e r _ f i l t e r _ a t t r i b u t e s , o r NULL∗ /

    # d e f i n e SCHEDULER_FILTER_TYPE_INIT ( f i l t e r _ t y p e , owner , name ,new , d e s t r o y ,g e t _ v a l u e , u p d a t e _ v a l u e , show_value ,g e t _ r e m o t e _ v a l u e ,s r c _ v a l u e _ t y p e ,s r c _ v a l u e _ t y p e _ s i z e ,s r c _ g e t _ p a r a m _ t y p e ,s r c _ g e t _ p a r a m _ t y p e _ s i z e ,s n k _ v a l u e _ t y p e ,s n k _ v a l u e _ t y p e _ s i z e ,snk_ge t_pa ram_type ,s n k _ g e t _ p a r a m _ t y p e _ s i z e ,_ a t t r s )

    33

  • D1.2 3.2 API for Component Programmers

    /∗∗ Convenience macros t o d e f i n e a s c h e d u l e r _ f i l t e r _ t y p e∗∗ These c o n v e n i e n c e macros s h o u l d be used t h e f o l l o w i n g way :∗∗ F i r s t , implemented methods must be d e f i n e d u s i n g t h e∗ DEFINE_SCHEDULER_FILTER_ macros . Second , t h e s c h e d u l e r _ f i l t e r _ t y p e∗ must be f i l l e d u s i n g {BEGIN ,END}_SCHEDULER_FILTER_TYPE and SCHEDULER_FILTER_∗∗ macros :∗∗ BEGIN_SCHEDULER_FILTER_TYPE ( name ) ,∗ . SCHEDULER_FILTER_SOURCE_VALUE_TYPE( name , t y p e ) ,∗ . SCHEDULER_FILTER_PORT_VALUE_TYPE( name , t y p e ) ,∗ i f needed :∗ . SCHEDULER_FILTER_( name ) ,∗ . SCHEDULER_FILTER_SOURCE_PARAM_TYPE( name , t y p e ) ,∗ . SCHEDULER_FILTER_PORT_PARAM_TYPE( name , t y p e ) ,∗ . SCHEDULER_FILTER_ATTRS( name , a t t r s ) ,∗ . . .∗ and f i n a l l y :∗ END_SCHEDULER_FILTER_TYPE( name ) ;∗ /

    /∗ ∗∗ Convenience macro t o s t a r t t h e d e f i n i t i o n o f a s c h e d u l e r _ f i l t e r _ t y p e . The∗ d e f i n i t i o n must end wi th END_SCHEDULER_FILTER_TYPE( name ) . The v a r i a b l e w i l l∗ be c a l l e d name_type .∗∗ @param name name of t h e s c h e d u l e r _ f i l t e r t y p e∗ /

    # d e f i n e BEGIN_SCHEDULER_FILTER_TYPE ( name )

    /∗ ∗∗ Convenience macro t o a t t a c h a p r e v i o u s l y d e f i n e d g e t _ v a l u e ( ) method t o a∗ s c h e d u l e r _ f i l t e r t y p e . The g e t _ v a l u e ( ) method must have been d e f i n e d e a r l i e r∗ wi th DEFINE_SCHEDULER_FILTER_GET_VALUE( name , . . . ) .∗∗ @param name must match t h