source: rtems/cpukit/rtems/src/regionprocessqueue.c @ 22788bc

4.115
Last change on this file since 22788bc was 22788bc, checked in by Sebastian Huber <sebastian.huber@…>, on 04/23/15 at 11:01:05

score: _Thread_queue_Extract()

Remove thread queue parameter from _Thread_queue_Extract() since the
current thread queue is stored in the thread control block.

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