source: rtems/cpukit/score/src/schedulercbsattachthread.c

Last change on this file was 80cf60e, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 15, 2020 at 7:48:32 AM

Canonicalize config.h include

Use the following variant which was already used by most source files:

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief Attach Scheduler CBS Thread
5 *  @ingroup RTEMSScoreScheduler
6 */
7
8/*
9 *  Copyright (C) 2011 Petr Benes.
10 *  Copyright (C) 2011 On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.org/license/LICENSE.
15 */
16
17#ifdef HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/score/schedulercbsimpl.h>
22#include <rtems/score/threadimpl.h>
23
24int _Scheduler_CBS_Attach_thread (
25  Scheduler_CBS_Server_id server_id,
26  rtems_id                task_id
27)
28{
29  Scheduler_CBS_Server *server;
30  ISR_lock_Context      lock_context;
31  Thread_Control       *the_thread;
32  Scheduler_CBS_Node   *node;
33
34  if ( server_id >= _Scheduler_CBS_Maximum_servers ) {
35    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
36  }
37
38  server = &_Scheduler_CBS_Server_list[ server_id ];
39
40  if ( !server->initialized ) {
41    return SCHEDULER_CBS_ERROR_NOSERVER;
42  }
43
44  if ( server->task_id != -1 ) {
45    return SCHEDULER_CBS_ERROR_FULL;
46  }
47
48  the_thread = _Thread_Get( task_id, &lock_context );
49
50  if ( the_thread == NULL ) {
51    return SCHEDULER_CBS_ERROR_INVALID_PARAMETER;
52  }
53
54  node = _Scheduler_CBS_Thread_get_node( the_thread );
55
56  if ( node->cbs_server != NULL ) {
57    _ISR_lock_ISR_enable( &lock_context );
58    return SCHEDULER_CBS_ERROR_FULL;
59  }
60
61  node->cbs_server = server;
62
63  server->task_id = task_id;
64
65  the_thread->budget_callout   = _Scheduler_CBS_Budget_callout;
66  the_thread->budget_algorithm = THREAD_CPU_BUDGET_ALGORITHM_CALLOUT;
67  the_thread->is_preemptible   = true;
68
69  _ISR_lock_ISR_enable( &lock_context );
70  return SCHEDULER_CBS_OK;
71}
Note: See TracBrowser for help on using the repository browser.