1/*
2Copyright (c) 2012, Broadcom Europe Ltd
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the copyright holder nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28/*=============================================================================
29VideoCore OS Abstraction Layer - thread attributes
30=============================================================================*/
31
32#ifndef VCOS_THREAD_ATTR_H
33#define VCOS_THREAD_ATTR_H
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/**
40 * \file
41 *
42 * Attributes for thread creation.
43 *
44 */
45
46/** Initialize thread attribute struct. This call does not allocate memory,
47 * and so cannot fail.
48 *
49 */
50VCOSPRE_ void VCOSPOST_ vcos_thread_attr_init(VCOS_THREAD_ATTR_T *attrs);
51
52/** Set the stack address and size. If not set, a stack will be allocated automatically.
53 *
54 * This can only be set on some platforms. It will always be possible to set the stack
55 * address on VideoCore, but on host platforms, support may well not be available.
56 */
57#if VCOS_CAN_SET_STACK_ADDR
58VCOS_INLINE_DECL
59void vcos_thread_attr_setstack(VCOS_THREAD_ATTR_T *attrs, void *addr, VCOS_UNSIGNED sz);
60#endif
61
62/** Set the stack size. If not set, a default size will be used. Attempting to call this after having
63 * set the stack location with vcos_thread_attr_setstack() will result in undefined behaviour.
64 */
65VCOS_INLINE_DECL
66void vcos_thread_attr_setstacksize(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED sz);
67
68/** Set the task priority. If not set, a default value will be used.
69 */
70VCOS_INLINE_DECL
71void vcos_thread_attr_setpriority(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED pri);
72
73/** Set the task cpu affinity. If not set, the default will be used.
74 */
75VCOS_INLINE_DECL
76void vcos_thread_attr_setaffinity(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED aff);
77
78/** Set the timeslice. If not set the default will be used.
79 */
80VCOS_INLINE_DECL
81void vcos_thread_attr_settimeslice(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED ts);
82
83/** The thread entry function takes (argc,argv), as per Nucleus, with
84 * argc being 0. This may be withdrawn in a future release and should not
85 * be used in new code.
86 */
87VCOS_INLINE_DECL
88void _vcos_thread_attr_setlegacyapi(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED legacy);
89
90VCOS_INLINE_DECL
91void vcos_thread_attr_setautostart(VCOS_THREAD_ATTR_T *attrs, VCOS_UNSIGNED autostart);
92
93#ifdef __cplusplus
94}
95#endif
96#endif
97