source: rtems/cpukit/score/src/schedulercbsdetachthread.c @ 08d9760

4.115
Last change on this file since 08d9760 was 08d9760, checked in by Sebastian Huber <sebastian.huber@…>, on 07/08/14 at 12:25:55

score: Rename *_Node_get() to *_Thread_get_node()

This emphasizes that the scheduler node of a thread is returned and this
is not a function working with scheduler nodes like the other *_Node_*()
functions.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 *
4 * @brief Detach from the CBS Server
5 *
6 * @ingroup ScoreScheduler
7 */
8
9/*
10 *  Copyright (C) 2011 Petr Benes.
11 *  Copyright (C) 2011 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.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/score/schedulercbsimpl.h>
23#include <rtems/score/threadimpl.h>
24
25int _Scheduler_CBS_Detach_thread (
26  Scheduler_CBS_Server_id server_id,
27  rtems_id                task_id
28)
29{
30  Objects_Locations location;
31  Thread_Control *the_thread;
32
33  if ( server_id >= _Scheduler_CBS_Maximum_servers )
34    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
35  /* Server is not valid. */
36  if ( !_Scheduler_CBS_Server_list[server_id].initialized )
37    return SCHEDULER_CBS_ERROR_NOSERVER;
38  /* Thread and server are not attached. */
39  if ( _Scheduler_CBS_Server_list[server_id].task_id != task_id )
40    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
41
42  the_thread = _Thread_Get(task_id, &location);
43  /* The routine _Thread_Get may disable dispatch and not enable again. */
44  if ( the_thread ) {
45    Scheduler_CBS_Node *node = _Scheduler_CBS_Thread_get_node( the_thread );
46
47    _Scheduler_CBS_Server_list[server_id].task_id = -1;
48    node->cbs_server = NULL;
49
50    the_thread->budget_algorithm = the_thread->Start.budget_algorithm;
51    the_thread->budget_callout   = the_thread->Start.budget_callout;
52    the_thread->is_preemptible   = the_thread->Start.is_preemptible;
53
54    _Objects_Put( &the_thread->Object );
55  } else {
56    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
57  }
58
59  return SCHEDULER_CBS_OK;
60}
Note: See TracBrowser for help on using the repository browser.