source: rtems/cpukit/score/include/rtems/score/mrsp.h @ 993f5ac

4.115
Last change on this file since 993f5ac was 9553e7a6, checked in by Sebastian Huber <sebastian.huber@…>, on 05/26/14 at 14:02:58

score: Use Resource Handler for MrsP semaphores

This enables proper resource dependency tracking and as a side-effect
deadlock detection.

  • Property mode set to 100644
File size: 3.4 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_INCORRECT_STATE = 14,
67  MRSP_INVALID_PRIORITY = 19,
68  MRSP_NOT_OWNER_OF_RESOURCE = 23,
69  MRSP_NO_MEMORY = 26
70} MRSP_Status;
71
72/**
73 * @brief MrsP rival.
74 *
75 * The rivals are used by threads waiting for resource ownership.  They are
76 * registered in the MRSP control block.
77 */
78typedef struct {
79  /**
80   * @brief The node for registration in the MRSP rival chain.
81   *
82   * @see MRSP_Control::Rivals.
83   */
84  Chain_Node Node;
85
86  /**
87   * @brief Identification of the rival thread.
88   */
89  Thread_Control *thread;
90
91  /**
92   * @brief The rival state.
93   *
94   * Initially no state bits are set (MRSP_RIVAL_STATE_WAITING).  The rival
95   * will busy wait until a state change happens.  This can be
96   * MRSP_RIVAL_STATE_NEW_OWNER or MRSP_RIVAL_STATE_TIMEOUT.
97   */
98  Atomic_Uint state;
99} MRSP_Rival;
100
101/**
102 * @brief MrsP control block.
103 */
104typedef struct {
105  /**
106   * @brief Basic resource control.
107   */
108  Resource_Control Resource;
109
110  /**
111   * @brief A chain of MrsP rivals waiting for resource ownership.
112   *
113   * @see MRSP_Rival::Node.
114   */
115  Chain_Control Rivals;
116
117  /**
118   * @brief The initial priority of the owner before it was elevated to the
119   * ceiling priority.
120   */
121  Priority_Control initial_priority_of_owner;
122
123  /**
124   * @brief One ceiling priority per scheduler instance.
125   */
126  Priority_Control *ceiling_priorities;
127} MRSP_Control;
128
129/** @} */
130
131#ifdef __cplusplus
132}
133#endif /* __cplusplus */
134
135#endif /* RTEMS_SMP */
136
137#endif /* _RTEMS_SCORE_MRSP_H */
Note: See TracBrowser for help on using the repository browser.