source: rtems/cpukit/posix/src/semaphorewaitsupp.c @ 97312fcc

5
Last change on this file since 97312fcc 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.7 KB
Line 
1/**
2 * @file
3 *
4 * @brief POSIX Semaphore Wait Support
5 * @ingroup POSIXSemaphorePrivate
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2012.
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 <stdarg.h>
22
23#include <errno.h>
24#include <fcntl.h>
25#include <pthread.h>
26#include <semaphore.h>
27#include <limits.h>
28
29#include <rtems/system.h>
30#include <rtems/score/threadimpl.h>
31#include <rtems/posix/semaphoreimpl.h>
32#include <rtems/seterr.h>
33
34THREAD_WAIT_QUEUE_OBJECT_ASSERT(
35  POSIX_Semaphore_Control,
36  Semaphore.Wait_queue
37);
38
39int _POSIX_Semaphore_Wait_support(
40  sem_t             *sem,
41  bool               blocking,
42  Watchdog_Interval  timeout
43)
44{
45  POSIX_Semaphore_Control *the_semaphore;
46  Objects_Locations        location;
47  Thread_Control          *executing;
48  ISR_lock_Context         lock_context;
49
50  the_semaphore = _POSIX_Semaphore_Get_interrupt_disable(
51    sem,
52    &location,
53    &lock_context
54  );
55  switch ( location ) {
56
57    case OBJECTS_LOCAL:
58      executing = _Thread_Executing;
59      _CORE_semaphore_Seize(
60        &the_semaphore->Semaphore,
61        executing,
62        the_semaphore->Object.id,
63        blocking,
64        timeout,
65        &lock_context
66      );
67
68      if ( !executing->Wait.return_code )
69        return 0;
70
71      rtems_set_errno_and_return_minus_one(
72        _POSIX_Semaphore_Translate_core_semaphore_return_code(
73          executing->Wait.return_code
74        )
75      );
76
77#if defined(RTEMS_MULTIPROCESSING)
78    case OBJECTS_REMOTE:
79#endif
80    case OBJECTS_ERROR:
81      break;
82  }
83
84  rtems_set_errno_and_return_minus_one( EINVAL );
85}
Note: See TracBrowser for help on using the repository browser.