source: rtems/cpukit/rtems/src/regionprocessqueue.c @ 66cb142

Last change on this file since 66cb142 was dce48791, checked in by Sebastian Huber <sebastian.huber@…>, on May 23, 2016 at 11:37:59 AM

score: Add Status_Control for all APIs

Unify the status codes of the Classic and POSIX API to use the new enum
Status_Control. This eliminates the Thread_Control::Wait::timeout_code
field and the timeout parameter of _Thread_queue_Enqueue_critical() and
_MPCI_Send_request_packet(). It gets rid of the status code translation
tables and instead uses simple bit operations to get the status for a
particular API. This enables translation of status code constants at
compile time. Add _Thread_Wait_get_status() to avoid direct access of
thread internal data structures.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Process Region Queue
5 *  @ingroup ClassicRegion
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-1999.
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 <rtems/rtems/regionimpl.h>
22#include <rtems/score/status.h>
23#include <rtems/score/threadqimpl.h>
24
25void _Region_Process_queue(
26  Region_Control *the_region
27)
28{
29  Per_CPU_Control *cpu_self;
30  Thread_Control  *the_thread;
31  void            *the_segment;
32
33  /*
34   *  Switch from using the memory allocation mutex to using a
35   *  dispatching disabled critical section.  We have to do this
36   *  because this thread may unblock one or more threads that were
37   *  waiting on memory.
38   *
39   *  NOTE: Be sure to disable dispatching before unlocking the mutex
40   *        since we do not want to open a window where a context
41   *        switch could occur.
42   */
43  cpu_self = _Thread_Dispatch_disable();
44  _Region_Unlock( the_region );
45
46  /*
47   *  NOTE: The following loop is O(n) where n is the number of
48   *        threads whose memory request is satisfied.
49   */
50  for ( ; ; ) {
51    the_thread = _Thread_queue_First(
52      &the_region->Wait_queue,
53      the_region->wait_operations
54    );
55
56    if ( the_thread == NULL )
57      break;
58
59    the_segment = (void **) _Region_Allocate_segment(
60      the_region,
61      the_thread->Wait.count
62    );
63
64    if ( the_segment == NULL )
65      break;
66
67    *(void **)the_thread->Wait.return_argument = the_segment;
68    _Thread_queue_Extract( the_thread );
69    the_thread->Wait.return_code = STATUS_SUCCESSFUL;
70  }
71
72  _Thread_Dispatch_enable( cpu_self );
73}
Note: See TracBrowser for help on using the repository browser.