source: rtems/cpukit/score/src/apimutexlock.c @ 0e1d11f3

5
Last change on this file since 0e1d11f3 was 0e1d11f3, checked in by Sebastian Huber <sebastian.huber@…>, on 05/27/16 at 11:26:53

score: Add _Thread_queue_Context_set_MP_callout()

Add _Thread_queue_Context_set_MP_callout() to simplify
_Thread_queue_Context_initialize(). This makes it possible to more
easily add additional fields to Thread_queue_Context.

  • Property mode set to 100644
File size: 1.1 KB
Line 
1/**
2 * @file
3 *
4 * @brief Acquires the specified API mutex.
5 *
6 * @ingroup ScoreAPIMutex
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2007.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  The license and distribution terms for this file may be
14 *  found in the file LICENSE in this distribution or at
15 *  http://www.rtems.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/score/apimutex.h>
23#include <rtems/score/coremuteximpl.h>
24#include <rtems/score/threadimpl.h>
25
26void _API_Mutex_Lock( API_Mutex_Control *the_mutex )
27{
28  Thread_Life_state    previous_thread_life_state;
29  Thread_queue_Context queue_context;
30
31  previous_thread_life_state =
32    _Thread_Set_life_protection( THREAD_LIFE_PROTECTED );
33
34  _Thread_queue_Context_initialize( &queue_context );
35  _ISR_lock_ISR_disable( &queue_context.Lock_context );
36
37  _CORE_mutex_Seize(
38    &the_mutex->Mutex,
39    _Thread_Executing,
40    true,
41    0,
42    &queue_context
43  );
44
45  if ( the_mutex->Mutex.nest_count == 1 ) {
46    the_mutex->previous_thread_life_state = previous_thread_life_state;
47  }
48}
Note: See TracBrowser for help on using the repository browser.