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

4.115
Last change on this file since c499856 was c499856, checked in by Chris Johns <chrisj@…>, on 03/20/14 at 21:10:47

Change all references of rtems.com to rtems.org.

  • 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/schedulercbs.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  Scheduler_CBS_Per_thread *sched_info;
33
34  if ( server_id >= _Scheduler_CBS_Maximum_servers )
35    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
36  /* Server is not valid. */
37  if ( !_Scheduler_CBS_Server_list[server_id] )
38    return SCHEDULER_CBS_ERROR_NOSERVER;
39  /* Thread and server are not attached. */
40  if ( _Scheduler_CBS_Server_list[server_id]->task_id != task_id )
41    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
42
43  the_thread = _Thread_Get(task_id, &location);
44  /* The routine _Thread_Get may disable dispatch and not enable again. */
45  if ( the_thread ) {
46    _Scheduler_CBS_Server_list[server_id]->task_id = -1;
47    sched_info = (Scheduler_CBS_Per_thread *) the_thread->scheduler_info;
48    sched_info->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.