Tizen RT Libs&Environment  v1.1 D4
sched.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 /********************************************************************************
19  * include/sched.h
20  *
21  * Copyright (C) 2007-2009, 2011, 2013 Gregory Nutt. All rights reserved.
22  * Author: Gregory Nutt <gnutt@nuttx.org>
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in
32  * the documentation and/or other materials provided with the
33  * distribution.
34  * 3. Neither the name NuttX nor the names of its contributors may be
35  * used to endorse or promote products derived from this software
36  * without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49  * POSSIBILITY OF SUCH DAMAGE.
50  *
51  ********************************************************************************/
58 
61 #ifndef __INCLUDE_SCHED_H
62 #define __INCLUDE_SCHED_H
63 
64 /********************************************************************************
65  * Included Files
66  ********************************************************************************/
67 
68 #include <tinyara/config.h>
69 
70 #include <sys/types.h>
71 #include <stdint.h>
72 #include <tinyara/sched.h>
73 
74 /********************************************************************************
75  * Pre-processor Definitions
76  ********************************************************************************/
77 
78 /* Task Management Definitions **************************************************/
79 
84 /* POSIX-like scheduling policies */
85 
86 #define SCHED_FIFO 1 /* FIFO per priority scheduling policy */
87 #define SCHED_RR 2 /* Round robin scheduling policy */
88 #define SCHED_SPORADIC 3 /* Not supported */
89 #define SCHED_OTHER 4 /* Not supported */
90 
91 
92 /* Cancellation definitions *****************************************************/
93 /* Cancellation states used by task_setcancelstate() */
94 #define TASK_CANCEL_ENABLE (0)
95 #define TASK_CANCEL_DISABLE (1)
96 /* Cancellation types used by task_setcanceltype() */
97 #define TASK_CANCEL_DEFERRED (0)
98 #define TASK_CANCEL_ASYNCHRONOUS (1)
99 
100 /* Pthread definitions **********************************************************/
101 
102 #define PTHREAD_KEYS_MAX CONFIG_NPTHREAD_KEYS
103 
107 /********************************************************************************
108  * Public Type Definitions
109  ********************************************************************************/
110 
115 struct sched_param {
117 };
118 
119 /********************************************************************************
120  * Public Data
121  ********************************************************************************/
122 
123 #ifndef __ASSEMBLY__
124 #undef EXTERN
125 #if defined(__cplusplus)
126 #define EXTERN extern "C"
127 extern "C" {
128 #else
129 #define EXTERN extern
130 #endif
131 
132 /********************************************************************************
133  * Public Function Prototypes
134  ********************************************************************************/
135 
136 /* Task Control Interfaces (non-standard) */
141 int task_init(FAR struct tcb_s *tcb, const char *name, int priority, FAR uint32_t *stack, uint32_t stack_size, main_t entry, FAR char *const argv[]);
145 int task_activate(FAR struct tcb_s *tcb);
146 
151 #ifndef CONFIG_BUILD_KERNEL
152 
178 int task_create(FAR const char *name, int priority, int stack_size, main_t entry, FAR char *const argv[]);
179 #endif
180 
211 int task_delete(pid_t pid);
212 
232 int task_restart(pid_t pid);
233 
234 int task_setcancelstate(int state, FAR int *oldstate);
235 int task_setcanceltype(int type, FAR int *oldtype);
236 void task_testcancel(void);
237 
238 /* Task Scheduling Interfaces (based on POSIX APIs) */
247 int sched_setparam(pid_t pid, const struct sched_param *param);
256 int sched_getparam(pid_t pid, struct sched_param *param);
265 int sched_setscheduler(pid_t pid, int policy, FAR const struct sched_param *param);
274 int sched_getscheduler(pid_t pid);
283 int sched_yield(void);//end for SCHED_KERNEL
287 
298 int sched_get_priority_max(int policy);
305 int sched_get_priority_min(int policy);
317 int sched_rr_get_interval(pid_t pid, FAR struct timespec *interval);
318 
319 /* Task Switching Interfaces (non-standard) */
328 int sched_lock(void);
343 int sched_unlock(void);
358 int sched_lockcount(void);
359 
360 /* If instrumentation of the scheduler is enabled, then some outboard logic
361  * must provide the following interfaces.
362  */
363 
364 #ifdef CONFIG_SCHED_INSTRUMENTATION
365 
369 void sched_note_start(FAR struct tcb_s *tcb);
373 void sched_note_stop(FAR struct tcb_s *tcb);
377 void sched_note_switch(FAR struct tcb_s *pFromTcb, FAR struct tcb_s *pToTcb);
378 
383 #else
384 #define sched_note_start(t)
385 #define sched_note_stop(t)
386 #define sched_note_switch(t1, t2)
387 #endif /* CONFIG_SCHED_INSTRUMENTATION */
388 
389 #undef EXTERN
390 #if defined(__cplusplus)
391 }
392 #endif
393 #endif /* __ASSEMBLY__ */
394 
395 #endif /* __INCLUDE_SCHED_H */
int task_setcanceltype(int type, FAR int *oldtype)
int task_delete(pid_t pid)
causes a specified task to cease to exist.
int sched_getscheduler(pid_t pid)
get scheduling policy and parameters
int sched_rr_get_interval(pid_t pid, FAR struct timespec *interval)
get execution time limits
int task_restart(pid_t pid)
restart a task.
int task_create(FAR const char *name, int priority, int stack_size, main_t entry, FAR char *const argv[])
creates and activates a new task with a specified priority and returns its system-assigned ID...
POSIX-like scheduling parameter structure.
Definition: sched.h:115
int sched_priority
Definition: sched.h:116
#define sched_note_switch(t1, t2)
Definition: sched.h:386
int task_setcancelstate(int state, FAR int *oldstate)
#define sched_note_stop(t)
Definition: sched.h:385
This is the common part of the task control block (TCB). The TCB is the heart of the TinyAra task-con...
Definition: sched.h:474
int sched_lock(void)
disable context switching
int sched_yield(void)
yield the processor
int sched_setparam(pid_t pid, const struct sched_param *param)
set scheduling parameters
int sched_lockcount(void)
returns the current value of the lockcount
void task_testcancel(void)
int sched_get_priority_min(int policy)
get priority limits
int sched_getparam(pid_t pid, struct sched_param *param)
get scheduling parameters
structure represents an elapsed time
Definition: time.h:152
#define sched_note_start(t)
Definition: sched.h:384
int sched_unlock(void)
re-enable the context switching which blocked from sched_lock()
int sched_setscheduler(pid_t pid, int policy, FAR const struct sched_param *param)
set scheduling policy and parameters
int sched_get_priority_max(int policy)
get priority limits