-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclock.h
More file actions
81 lines (54 loc) · 1.26 KB
/
clock.h
File metadata and controls
81 lines (54 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
** SCCS ID: @(#)clock.h 1.1 4/17/15
**
** File: clock.h
**
** Author: CSCI-452 class of 20145
**
** Contributor:
**
** Description: Clock module
*/
#ifndef _CLOCK_H_
#define _CLOCK_H_
#include "types.h"
/*
** General (C and/or assembly) definitions
*/
// clock interrupts per second
#define CLOCK_FREQUENCY 1000
// standard process quantum (in ticks)
#define QUANTUM_DEFAULT 10
#ifndef __SP_ASM__
/*
** Start of C-only definitions
*/
// pseudo function to convert seconds to milliseconds
#define SECONDS_TO_MS(n) ((n) * 1000)
// pseudo function to convert milliseconds to clock ticks
// (currently, a no-op, as the base clock rate is 1000 ticks/sec)
#define MS_TO_TICKS(n) ((n))
// pseudo function to convert seconds to ticks
#define SECONDS_TO_TICKS(n) (MS_TO_TICKS(SECONDS_TO_MS((n))))
// pseudo function to convert ticks to (truncated) seconds
#define TICKS_TO_SECONDS(n) ((n) / CLOCK_FREQUENCY)
// pseudo function to convert ticks to (rounded up) seconds
#define TICKS_TO_ROUNDED_SECONDS(n) (((n)+(CLOCK_FREQUENCY-1)) / CLOCK_FREQUENCY)
/*
** Types
*/
/*
** Globals
*/
extern uint32_t _system_time; // the current system time
/*
** Prototypes
*/
/*
** _clock_modinit()
**
** initialize the clock module
*/
void _clock_modinit( void );
#endif
#endif