Tizen RT Libs&Environment  v1.0 D5
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 /* Pthread definitions **********************************************************/
92 
93 #define PTHREAD_KEYS_MAX CONFIG_NPTHREAD_KEYS
94 
97 /********************************************************************************
98  * Public Type Definitions
99  ********************************************************************************/
100 
105 struct sched_param {
107 };
108 
109 /********************************************************************************
110  * Public Data
111  ********************************************************************************/
112 
113 #ifndef __ASSEMBLY__
114 #undef EXTERN
115 #if defined(__cplusplus)
116 #define EXTERN extern "C"
117 extern "C" {
118 #else
119 #define EXTERN extern
120 #endif
121 
122 /********************************************************************************
123  * Public Function Prototypes
124  ********************************************************************************/
125 
126 /* Task Control Interfaces (non-standard) */
131 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[]);
135 int task_activate(FAR struct tcb_s *tcb);
136 
141 #ifndef CONFIG_BUILD_KERNEL
142 
167 int task_create(FAR const char *name, int priority, int stack_size, main_t entry, FAR char *const argv[]);
168 #endif
169 
199 int task_delete(pid_t pid);
200 
219 int task_restart(pid_t pid);
220 
221 /* Task Scheduling Interfaces (based on POSIX APIs) */
228 int sched_setparam(pid_t pid, const struct sched_param *param);
235 int sched_getparam(pid_t pid, struct sched_param *param);
242 int sched_setscheduler(pid_t pid, int policy, FAR const struct sched_param *param);
249 int sched_getscheduler(pid_t pid);
256 int sched_yield(void);//end for SCHED_KERNEL
259 
268 int sched_get_priority_max(int policy);
273 int sched_get_priority_min(int policy);
282 int sched_rr_get_interval(pid_t pid, FAR struct timespec *interval);
283 
284 /* Task Switching Interfaces (non-standard) */
292 int sched_lock(void);
306 int sched_unlock(void);
320 int sched_lockcount(void);
321 
322 /* If instrumentation of the scheduler is enabled, then some outboard logic
323  * must provide the following interfaces.
324  */
325 
326 #ifdef CONFIG_SCHED_INSTRUMENTATION
327 
331 void sched_note_start(FAR struct tcb_s *tcb);
335 void sched_note_stop(FAR struct tcb_s *tcb);
339 void sched_note_switch(FAR struct tcb_s *pFromTcb, FAR struct tcb_s *pToTcb);
340 
345 #else
346 #define sched_note_start(t)
347 #define sched_note_stop(t)
348 #define sched_note_switch(t1, t2)
349 #endif /* CONFIG_SCHED_INSTRUMENTATION */
350 
351 #undef EXTERN
352 #if defined(__cplusplus)
353 }
354 #endif
355 #endif /* __ASSEMBLY__ */
356 
357 #endif /* __INCLUDE_SCHED_H */
int task_delete(pid_t pid)
causes a specified task to cease to exist.
int sched_getscheduler(pid_t pid)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int sched_rr_get_interval(pid_t pid, FAR struct timespec *interval)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
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:105
int sched_priority
Definition: sched.h:106
#define sched_note_switch(t1, t2)
Definition: sched.h:348
#define sched_note_stop(t)
Definition: sched.h:347
This is the common part of the task control block (TCB). The TCB is the heart of the TinyAra task-con...
Definition: sched.h:456
int sched_lock(void)
disable context switching
int sched_yield(void)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int sched_setparam(pid_t pid, const struct sched_param *param)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int sched_lockcount(void)
returns the current value of the lockcount
int sched_get_priority_min(int policy)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int sched_getparam(pid_t pid, struct sched_param *param)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
structure represents an elapsed time
Definition: time.h:152
#define sched_note_start(t)
Definition: sched.h:346
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)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)
int sched_get_priority_max(int policy)
POSIX APIs (refer to : http://pubs.opengroup.org/onlinepubs/9699919799/)