source: rtems/cpukit/score/src/schedulercbsdetachthread.c @ 04bf7cb

4.11
Last change on this file since 04bf7cb was 04bf7cb, checked in by Ralf Corsepius <ralf.corsepius@…>, on Dec 6, 2011 at 7:12:42 AM

2011-12-06 Ralf Corsépius <ralf.corsepius@…>

  • score/src/schedulercbsattachthread.c, score/src/schedulercbsdestroyserver.c, score/src/schedulercbsdetachthread.c, score/src/schedulercbsgetapprovedbudget.c, score/src/schedulercbsgetexecutiontime.c, score/src/schedulercbsgetparameters.c, score/src/schedulercbsgetremainingbudget.c, score/src/schedulercbssetparameters.c: Remove checks for server_id < 0 (server_id is unsigned).
  • Property mode set to 100644
File size: 1.7 KB
Line 
1/*
2 *  Copyright (C) 2011 Petr Benes.
3 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
8 *
9 *  $Id$
10 */
11
12#if HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <rtems/system.h>
17#include <rtems/config.h>
18#include <rtems/score/scheduler.h>
19#include <rtems/score/schedulercbs.h>
20
21int _Scheduler_CBS_Detach_thread (
22  Scheduler_CBS_Server_id server_id,
23  rtems_id                task_id
24)
25{
26  Objects_Locations location;
27  Thread_Control *the_thread;
28  Scheduler_CBS_Per_thread *sched_info;
29
30  the_thread = _Thread_Get(task_id, &location);
31  /* The routine _Thread_Get may disable dispatch and not enable again. */
32  if ( the_thread ) {
33    _Thread_Enable_dispatch();
34  }
35
36  if ( server_id >= _Scheduler_CBS_Maximum_servers )
37    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
38  if ( !the_thread )
39    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
40  /* Server is not valid. */
41  if ( !_Scheduler_CBS_Server_list[server_id] )
42    return SCHEDULER_CBS_ERROR_NOSERVER;
43  /* Thread and server are not attached. */
44  if ( _Scheduler_CBS_Server_list[server_id]->task_id != task_id )
45    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
46
47  _Scheduler_CBS_Server_list[server_id]->task_id = -1;
48  sched_info = (Scheduler_CBS_Per_thread *) the_thread->scheduler_info;
49  sched_info->cbs_server = NULL;
50
51  the_thread->budget_algorithm = the_thread->Start.budget_algorithm;
52  the_thread->budget_callout   = the_thread->Start.budget_callout;
53  the_thread->is_preemptible   = the_thread->Start.is_preemptible;
54
55  return SCHEDULER_CBS_OK;
56}
Note: See TracBrowser for help on using the repository browser.