TizenRT Libs&Environment  v2.0 M2
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 
103 /********************************************************************************
104  * Public Type Definitions
105  ********************************************************************************/
106 
111 struct sched_param {
113 };
114 
115 /********************************************************************************
116  * Public Data
117  ********************************************************************************/
118 
119 #ifndef __ASSEMBLY__
120 #undef EXTERN
121 #if defined(__cplusplus)
122 #define EXTERN extern "C"
123 extern "C" {
124 #else
125 #define EXTERN extern
126 #endif
127 
128 /********************************************************************************
129  * Public Function Prototypes
130  ********************************************************************************/
131 
132 /* Task Control Interfaces (non-standard) */
137 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[]);
141 int task_activate(FAR struct tcb_s *tcb);
142 
147 #ifndef CONFIG_BUILD_KERNEL
148 
172 int task_create(FAR const char *name, int priority, int stack_size, main_t entry, FAR char *const argv[]);
173 #endif
174 
205 int task_delete(pid_t pid);
206 
226 int task_restart(pid_t pid);
227 
228 int task_setcancelstate(int state, FAR int *oldstate);
229 int task_setcanceltype(int type, FAR int *oldtype);
230 void task_testcancel(void);
231 
232 /* Task Scheduling Interfaces (based on POSIX APIs) */
241 int sched_setparam(pid_t pid, const struct sched_param *param);
250 int sched_getparam(pid_t pid, struct sched_param *param);
259 int sched_setscheduler(pid_t pid, int policy, FAR const struct sched_param *param);
268 int sched_getscheduler(pid_t pid);
277 int sched_yield(void);//end for SCHED_KERNEL
281 
292 int sched_get_priority_max(int policy);
299 int sched_get_priority_min(int policy);
311 int sched_rr_get_interval(pid_t pid, FAR struct timespec *interval);
312 
313 /* Task Switching Interfaces (non-standard) */
322 int sched_lock(void);
337 int sched_unlock(void);
352 int sched_lockcount(void);
353 
354 #undef EXTERN
355 #if defined(__cplusplus)
356 }
357 #endif
358 #endif /* __ASSEMBLY__ */
359 
360 #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:111
int sched_priority
Definition: sched.h:112
int task_setcancelstate(int state, FAR int *oldstate)
This is the common part of the task control block (TCB). The TCB is the heart of the TinyAra task-con...
Definition: sched.h:471
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:160
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