source: rtems/cpukit/score/src/coresemseize.c @ 4fc370e

4.115
Last change on this file since 4fc370e was d4d7899, checked in by Christopher Kerl <zargyyoyo@…>, on 11/28/12 at 19:31:53

score misc: Clean up Doxygen #2 (GCI 2012)

This patch is a task from GCI 2012 which improves the Doxygen
comments in the RTEMS source.

http://www.google-melange.com/gci/task/view/google/gci2012/7986213

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/**
2 * @file
3 *
4 * @brief Core Semaphore Seize
5 *
6 * @ingroup ScoreSemaphore
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2008.
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.com/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/system.h>
23#include <rtems/score/isr.h>
24#include <rtems/score/coresem.h>
25#include <rtems/score/states.h>
26#include <rtems/score/thread.h>
27#include <rtems/score/threadq.h>
28
29#if defined(RTEMS_SCORE_CORESEM_ENABLE_SEIZE_BODY)
30
31void _CORE_semaphore_Seize(
32  CORE_semaphore_Control *the_semaphore,
33  Objects_Id              id,
34  bool                    wait,
35  Watchdog_Interval       timeout
36)
37{
38  Thread_Control *executing;
39  ISR_Level       level;
40
41  executing = _Thread_Executing;
42  executing->Wait.return_code = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
43  _ISR_Disable( level );
44  if ( the_semaphore->count != 0 ) {
45    the_semaphore->count -= 1;
46    _ISR_Enable( level );
47    return;
48  }
49
50  /*
51   *  If the semaphore was not available and the caller was not willing
52   *  to block, then return immediately with a status indicating that
53   *  the semaphore was not available and the caller never blocked.
54   */
55  if ( !wait ) {
56    _ISR_Enable( level );
57    executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
58    return;
59  }
60
61  /*
62   *  If the semaphore is not available and the caller is willing to
63   *  block, then we now block the caller with optional timeout.
64   */
65  _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue );
66  executing->Wait.queue = &the_semaphore->Wait_queue;
67  executing->Wait.id    = id;
68  _ISR_Enable( level );
69  _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
70}
71#endif
Note: See TracBrowser for help on using the repository browser.