diff options
Diffstat (limited to 'sem3/osc/mm1')
-rw-r--r-- | sem3/osc/mm1/mm1/jmod.c | 9 | ||||
-rw-r--r-- | sem3/osc/mm1/mm2/tprog.c | 14 |
2 files changed, 14 insertions, 9 deletions
diff --git a/sem3/osc/mm1/mm1/jmod.c b/sem3/osc/mm1/mm1/jmod.c index a07077c..472ad46 100644 --- a/sem3/osc/mm1/mm1/jmod.c +++ b/sem3/osc/mm1/mm1/jmod.c @@ -8,7 +8,8 @@ static int major_num; static int busy; -static int cool_open(struct inode *inode, struct file *file) { +static int cool_open(struct inode *inode, struct file *file) +{ /* Check if we are already serving someone */ if (busy) { return -EBUSY; @@ -18,13 +19,15 @@ static int cool_open(struct inode *inode, struct file *file) { return 0; } -static int cool_release (struct inode *inode, struct file *file) { +static int cool_release (struct inode *inode, struct file *file) +{ busy = 0; return 0; } -static ssize_t cool_read (struct file *filp, char *buffer, size_t len, loff_t *offset) { +static ssize_t cool_read (struct file *filp, char *buffer, size_t len, loff_t *offset) +{ char str[12] = "hej med dig"; int i; diff --git a/sem3/osc/mm1/mm2/tprog.c b/sem3/osc/mm1/mm2/tprog.c index 377555f..bb04778 100644 --- a/sem3/osc/mm1/mm2/tprog.c +++ b/sem3/osc/mm1/mm2/tprog.c @@ -10,7 +10,8 @@ struct itimerval timer; -void timer_handler(int signum) { +void timer_handler(int signum) +{ /* Handy structure reference */ struct timeval *tv = &timer.it_value; printf("Hey we hit the alarm\n\a"); @@ -22,9 +23,9 @@ void timer_handler(int signum) { if (tv->tv_usec == 0) { tv->tv_usec = 999999; } else if (tv->tv_usec > ENDUSEC) { - tv->tv_usec *= SPEED; + tv->tv_usec *= SPEED; if (tv->tv_usec < ENDUSEC) { - tv->tv_usec = ENDUSEC; + tv->tv_usec = ENDUSEC; } } else { /* Return letting the timer be set to ENDUSEC */ @@ -36,12 +37,13 @@ void timer_handler(int signum) { /* Set alarm */ int err = setitimer(ITIMER_REAL, &timer, NULL); if (err) { - printf("Hey we got an error guys\n"); - exit(1); + printf("Hey we got an error guys\n"); + exit(1); } } -int main() { +int main() +{ /* Setup handler for timer */ struct sigaction sa; memset(&sa, 0, sizeof(sa)); /* Remeber to set all fields to zero */ |