source: trunk/kernel/kern/alarm.h @ 365

Last change on this file since 365 was 23, checked in by alain, 7 years ago

Introduce syscalls.

File size: 2.8 KB
Line 
1/*
2 * time.h: thread time related management
3 *
4 * Copyright (c) 2008,2009,2010,2011,2012 Ghassan Almaless
5 * Copyright (c) 2011,2012 UPMC Sorbonne Universites
6 *
7 * This file is part of ALMOS-kernel.
8 *
9 * ALMOS-kernel is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; version 2.0 of the License.
12 *
13 * ALMOS-kernel is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with ALMOS-kernel; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23#ifndef _TIME_H_
24#define _TIME_H_
25
26#include <types.h>
27#include <list.h>
28#include <device.h>
29
30struct event_s;
31
32struct alarm_info_s
33{
34        uint_t signature;
35
36        /* Public members */
37        struct event_s *event;
38
39        /* Private members */
40        uint_t tm_wakeup;
41        struct list_entry list;
42};
43
44struct alarm_s
45{ 
46        struct list_entry wait_queue;
47};
48
49
50struct timeb {
51        time_t         time;
52        unsigned short millitm;
53        short          timezone;
54        short          dstflag;
55};
56
57struct timeval {
58        clock_t tv_sec;    /* secondes */
59        clock_t tv_usec;   /* microsecondes */
60};
61
62struct timezone {
63        int tz_minuteswest;     /* minutes west of Greenwich */
64        int tz_dsttime;         /* type of DST correction */
65};
66
67
68struct tms
69{
70       clock_t tms_utime;  /* user time */
71       clock_t tms_stime;  /* system time */
72       clock_t tms_cutime; /* user time of children */
73       clock_t tms_cstime; /* system time of children */
74};
75
76
77error_t alarm_manager_init(struct alarm_s *alarm);
78error_t alarm_wait(struct alarm_info_s *info, uint_t msec);
79
80void alarm_clock(struct alarm_s *alarm, uint_t ticks_nr);
81
82int sys_clock (uint64_t *val);
83int sys_alarm (unsigned nb_sec);
84int sys_ftime (struct timeb *utime);
85int sys_times(struct tms *utms);
86int sys_gettimeofday(struct timeval *tv, struct timezone *tz);
87
88#if CONFIG_THREAD_TIME_STAT
89struct thread_s;
90inline void tm_sleep_compute(struct thread_s *thread);
91inline void tm_usr_compute(struct thread_s *thread);
92inline void tm_sys_compute(struct thread_s *thread);
93inline void tm_wait_compute(struct thread_s *thread);
94inline void tm_exit_compute(struct thread_s *thread);
95inline void tm_born_compute(struct thread_s *thread);
96inline void tm_create_compute(struct thread_s *thread);
97
98#else
99
100#define tm_sleep_compute(thread)
101#define tm_usr_compute(thread)
102#define tm_sys_compute(thread)
103#define tm_wait_compute(thread)
104#define tm_exit_compute(thread)
105#define tm_born_compute(thread)
106#define tm_create_compute(thread)
107
108#endif  /* CONFIG_SCHED_STAT */
109
110#endif  /* _TIME_H_ */
Note: See TracBrowser for help on using the repository browser.