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

4.115
Last change on this file since c05d7502 was c05d7502, checked in by Mathew Kallada <matkallada@…>, on 12/02/12 at 22:59:17

score misc: Clean up Doxygen #14 (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/8025204

  • Property mode set to 100644
File size: 1.9 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.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/rtems/status.h>
23#include <rtems/rtems/support.h>
24#include <rtems/score/object.h>
25#include <rtems/rtems/options.h>
26#include <rtems/rtems/region.h>
27#include <rtems/score/states.h>
28#include <rtems/score/thread.h>
29#include <rtems/score/apimutex.h>
30
31void _Region_Process_queue(
32  Region_Control *the_region
33)
34{
35  Thread_Control *the_thread;
36  void           *the_segment;
37  /*
38   *  Switch from using the memory allocation mutex to using a
39   *  dispatching disabled critical section.  We have to do this
40   *  because this thread may unblock one or more threads that were
41   *  waiting on memory.
42   *
43   *  NOTE: Be sure to disable dispatching before unlocking the mutex
44   *        since we do not want to open a window where a context
45   *        switch could occur.
46   */
47  _Thread_Disable_dispatch();
48  _RTEMS_Unlock_allocator();
49
50  /*
51   *  NOTE: The following loop is O(n) where n is the number of
52   *        threads whose memory request is satisfied.
53   */
54  for ( ; ; ) {
55    the_thread = _Thread_queue_First( &the_region->Wait_queue );
56
57    if ( the_thread == NULL )
58      break;
59
60    the_segment = (void **) _Region_Allocate_segment(
61      the_region,
62      the_thread->Wait.count
63    );
64
65    if ( the_segment == NULL )
66      break;
67
68    *(void **)the_thread->Wait.return_argument = the_segment;
69    the_region->number_of_used_blocks += 1;
70    _Thread_queue_Extract( &the_region->Wait_queue, the_thread );
71    the_thread->Wait.return_code = RTEMS_SUCCESSFUL;
72  }
73  _Thread_Enable_dispatch();
74}
Note: See TracBrowser for help on using the repository browser.