source: rtems/cpukit/posix/src/mutexlocksupp.c @ 04da96c7

5
Last change on this file since 04da96c7 was 97312fcc, checked in by Sebastian Huber <sebastian.huber@…>, on 04/05/16 at 12:36:30

score: Delete Thread_Wait_information::id

This field was only by the monitor in non-multiprocessing
configurations. Add new field Thread_Wait_information::remote_id in
multiprocessing configurations and use it for the remote procedure call
thread queue.

Add _Thread_Wait_get_id() to obtain the object identifier for debug and
system information tools. Ensure the object layout via static asserts.
Add test cases to sptests/spthreadq01.

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief Support Call to function Enables Locking of Mutex Object
5 * @ingroup POSIXAPI
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2014.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <errno.h>
22#include <pthread.h>
23
24#include <rtems/system.h>
25#include <rtems/score/coremuteximpl.h>
26#include <rtems/score/watchdog.h>
27#include <rtems/score/threadimpl.h>
28#include <rtems/posix/muteximpl.h>
29#include <rtems/posix/priorityimpl.h>
30
31THREAD_WAIT_QUEUE_OBJECT_ASSERT( POSIX_Mutex_Control, Mutex.Wait_queue );
32
33/*
34 *  _POSIX_Mutex_Lock_support
35 *
36 *  A support routine which implements guts of the blocking, non-blocking, and
37 *  timed wait version of mutex lock.
38 */
39
40int _POSIX_Mutex_Lock_support(
41  pthread_mutex_t           *mutex,
42  bool                       blocking,
43  Watchdog_Interval          timeout
44)
45{
46  POSIX_Mutex_Control          *the_mutex;
47  Objects_Locations             location;
48  ISR_lock_Context              lock_context;
49  Thread_Control               *executing;
50
51  the_mutex = _POSIX_Mutex_Get_interrupt_disable(
52    mutex,
53    &location,
54    &lock_context
55  );
56  switch ( location ) {
57
58    case OBJECTS_LOCAL:
59      executing = _Thread_Executing;
60      _CORE_mutex_Seize(
61        &the_mutex->Mutex,
62        executing,
63        the_mutex->Object.id,
64        blocking,
65        timeout,
66        &lock_context
67      );
68      return _POSIX_Mutex_Translate_core_mutex_return_code(
69        (CORE_mutex_Status) executing->Wait.return_code
70      );
71
72#if defined(RTEMS_MULTIPROCESSING)
73    case OBJECTS_REMOTE:
74#endif
75    case OBJECTS_ERROR:
76      break;
77  }
78
79  return EINVAL;
80}
Note: See TracBrowser for help on using the repository browser.