source: rtems/cpukit/score/src/schedulercbsdetachthread.c @ c398c66

4.115
Last change on this file since c398c66 was 4fc370e, checked in by Sebastian Huber <sebastian.huber@…>, on Jun 5, 2013 at 10:08:23 AM

score: Move thread dispatch content to new file

Move thread dispatch declarations and inline functions to new header
<rtems/score/threaddispatch.h> to make it independent of the
Thread_Control structure. This avoids a cyclic dependency in case
thread dispatch functions are used for the object implementation.

  • Property mode set to 100644
File size: 1.8 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.com/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/system.h>
23#include <rtems/config.h>
24#include <rtems/score/scheduler.h>
25#include <rtems/score/schedulercbs.h>
26#include <rtems/score/threaddispatch.h>
27
28int _Scheduler_CBS_Detach_thread (
29  Scheduler_CBS_Server_id server_id,
30  rtems_id                task_id
31)
32{
33  Objects_Locations location;
34  Thread_Control *the_thread;
35  Scheduler_CBS_Per_thread *sched_info;
36
37  the_thread = _Thread_Get(task_id, &location);
38  /* The routine _Thread_Get may disable dispatch and not enable again. */
39  if ( the_thread ) {
40    _Thread_Enable_dispatch();
41  }
42
43  if ( server_id >= _Scheduler_CBS_Maximum_servers )
44    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
45  if ( !the_thread )
46    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
47  /* Server is not valid. */
48  if ( !_Scheduler_CBS_Server_list[server_id] )
49    return SCHEDULER_CBS_ERROR_NOSERVER;
50  /* Thread and server are not attached. */
51  if ( _Scheduler_CBS_Server_list[server_id]->task_id != task_id )
52    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
53
54  _Scheduler_CBS_Server_list[server_id]->task_id = -1;
55  sched_info = (Scheduler_CBS_Per_thread *) the_thread->scheduler_info;
56  sched_info->cbs_server = NULL;
57
58  the_thread->budget_algorithm = the_thread->Start.budget_algorithm;
59  the_thread->budget_callout   = the_thread->Start.budget_callout;
60  the_thread->is_preemptible   = the_thread->Start.is_preemptible;
61
62  return SCHEDULER_CBS_OK;
63}
Note: See TracBrowser for help on using the repository browser.