source: rtems/cpukit/score/include/rtems/score/mrsp.h @ 8e7db68c

4.115
Last change on this file since 8e7db68c was 8fcafdd5, checked in by Sebastian Huber <sebastian.huber@…>, on 05/21/14 at 08:33:43

score: Multiprocessor Resource Sharing Protocol

Add basic support for the Multiprocessor Resource Sharing Protocol
(MrsP).

The Multiprocessor Resource Sharing Protocol (MrsP) is defined in A.
Burns and A.J. Wellings, A Schedulability Compatible Multiprocessor
Resource Sharing Protocol - MrsP, Proceedings of the 25th Euromicro
Conference on Real-Time Systems (ECRTS 2013), July 2013. It is a
generalization of the Priority Ceiling Protocol to SMP systems. Each
MrsP semaphore uses a ceiling priority per scheduler instance. These
ceiling priorities can be specified with rtems_semaphore_set_priority().
A task obtaining or owning a MrsP semaphore will execute with the
ceiling priority for its scheduler instance as specified by the MrsP
semaphore object. Tasks waiting to get ownership of a MrsP semaphore
will not relinquish the processor voluntarily. In case the owner of a
MrsP semaphore gets preempted it can ask all tasks waiting for this
semaphore to help out and temporarily borrow the right to execute on one
of their assigned processors.

The help out feature is not implemented with this patch.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1/*
2 * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#ifndef _RTEMS_SCORE_MRSP_H
16#define _RTEMS_SCORE_MRSP_H
17
18#include <rtems/score/cpuopts.h>
19
20#if defined(RTEMS_SMP)
21
22#include <rtems/score/atomic.h>
23#include <rtems/score/chain.h>
24#include <rtems/score/thread.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif /* __cplusplus */
29
30/**
31 * @defgroup ScoreMRSP Multiprocessor Resource Sharing Protocol Handler
32 *
33 * @ingroup Score
34 *
35 * @brief Multiprocessor Resource Sharing Protocol (MrsP).
36 *
37 * The Multiprocessor Resource Sharing Protocol (MrsP) is defined in A.  Burns
38 * and A.J.  Wellings, A Schedulability Compatible Multiprocessor Resource
39 * Sharing Protocol - MrsP, Proceedings of the 25th Euromicro Conference on
40 * Real-Time Systems (ECRTS 2013), July 2013.  It is a generalization of the
41 * Priority Ceiling Protocol to SMP systems.  Each MrsP semaphore uses a
42 * ceiling priority per scheduler instance.  A task obtaining or owning a MrsP
43 * semaphore will execute with the ceiling priority for its scheduler instance
44 * as specified by the MrsP semaphore object.  Tasks waiting to get ownership
45 * of a MrsP semaphore will not relinquish the processor voluntarily.  In case
46 * the owner of a MrsP semaphore gets preempted it can ask all tasks waiting
47 * for this semaphore to help out and temporarily borrow the right to execute
48 * on one of their assigned processors.
49 *
50 * @{
51 */
52
53/**
54 * @brief MrsP status code.
55 *
56 * The values are chosen to directly map to RTEMS status codes.  In case this
57 * implementation is used for other APIs, then for example the errno values can
58 * be added with a bit shift.
59 */
60typedef enum {
61  MRSP_SUCCESSFUL = 0,
62  MRSP_TIMEOUT = 6,
63  MRSP_INVALID_NUMBER = 10,
64  MRSP_RESOUCE_IN_USE = 12,
65  MRSP_UNSATISFIED = 13,
66  MRSP_INVALID_PRIORITY = 19,
67  MRSP_NOT_OWNER_OF_RESOURCE = 23,
68  MRSP_NO_MEMORY = 26
69} MRSP_Status;
70
71/**
72 * @brief MrsP rival.
73 *
74 * The rivals are used by threads waiting for resource ownership.  They are
75 * registered in the MRSP control block.
76 */
77typedef struct {
78  /**
79   * @brief The node for registration in the MRSP rival chain.
80   *
81   * @see MRSP_Control::Rivals.
82   */
83  Chain_Node Node;
84
85  /**
86   * @brief Identification of the rival thread.
87   */
88  Thread_Control *thread;
89
90  /**
91   * @brief The rival state.
92   *
93   * Initially no state bits are set (MRSP_RIVAL_STATE_WAITING).  The rival
94   * will busy wait until a state change happens.  This can be
95   * MRSP_RIVAL_STATE_NEW_OWNER or MRSP_RIVAL_STATE_TIMEOUT.
96   */
97  Atomic_Uint state;
98} MRSP_Rival;
99
100/**
101 * @brief MrsP control block.
102 */
103typedef struct {
104  /**
105   * @brief The owner of the MRSP resource.
106   *
107   * In case this field is @c NULL, then this MRSP resource has currently no
108   * owner.
109   */
110  Thread_Control *owner;
111
112  /**
113   * @brief A chain of MrsP rivals waiting for resource ownership.
114   *
115   * @see MRSP_Rival::Node.
116   */
117  Chain_Control Rivals;
118
119  /**
120   * @brief One ceiling priority per scheduler instance.
121   */
122  Priority_Control *ceiling_priorities;
123} MRSP_Control;
124
125/** @} */
126
127#ifdef __cplusplus
128}
129#endif /* __cplusplus */
130
131#endif /* RTEMS_SMP */
132
133#endif /* _RTEMS_SCORE_MRSP_H */
Note: See TracBrowser for help on using the repository browser.