source: rtems/cpukit/score/src/schedulercbsdetachthread.c @ 0daa8ab

5
Last change on this file since 0daa8ab was e266d13, checked in by Sebastian Huber <sebastian.huber@…>, on 05/20/16 at 13:10:27

Replace *_Get_interrupt_disable() with *_Get()

Uniformly use *_Get() to get an object by identifier with a lock
context.

  • Property mode set to 100644
File size: 1.6 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  Scheduler_CBS_Server *server;
31  ISR_lock_Context      lock_context;
32  Thread_Control       *the_thread;
33  Scheduler_CBS_Node   *node;
34
35  if ( server_id >= _Scheduler_CBS_Maximum_servers ) {
36    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
37  }
38
39  server = &_Scheduler_CBS_Server_list[ server_id ];
40
41  if ( !server->initialized ) {
42    return SCHEDULER_CBS_ERROR_NOSERVER;
43  }
44
45  if ( server->task_id != task_id ) {
46    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
47  }
48
49  the_thread = _Thread_Get( task_id, &lock_context );
50
51  if ( the_thread == NULL ) {
52    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
53  }
54
55  node = _Scheduler_CBS_Thread_get_node( the_thread );
56  node->cbs_server = NULL;
57
58  server->task_id = -1;
59
60  the_thread->budget_algorithm = the_thread->Start.budget_algorithm;
61  the_thread->budget_callout   = the_thread->Start.budget_callout;
62  the_thread->is_preemptible   = the_thread->Start.is_preemptible;
63
64  _ISR_lock_ISR_enable( &lock_context );
65  return SCHEDULER_CBS_OK;
66}
Note: See TracBrowser for help on using the repository browser.