source: rtems/cpukit/rtems/src/regionprocessqueue.c @ d887c1b

5
Last change on this file since d887c1b was b4b062f, checked in by Sebastian Huber <sebastian.huber@…>, on 04/08/16 at 05:50:42

rtems: Delete Region_Control::number_of_used_blocks

Use Heap_Statistics::used_blocks instead.

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