My Blog

Recording Technology and Life

Task 1: Modify a Dummy Read-Only File

1. create a dummy file

3

we can see that if we try to write to this file as a normal user, we will fail, because the file is only readable to normal users.

阅读全文 »

Task 1: Create and Install a Kernel Module

simple_module.c

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* simple_module.c */
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <asm/io.h>

static int __init simple_module_init(void)
{
printk("Helloworld.\n");
return 0;
}
/*
*The cleanup function of the module.
*/
static void __exit simple_module_exit(void)
{
printk(KERN_INFO"Exit.\n");
}
module_init(simple_module_init);
module_exit(simple_module_exit);

阅读全文 »

Exercise 1: Consider the following grammar G, which you have seen in the previous assignment:

1
2
3
4
5
6
7
E -> TX
X -> +E | ε
T -> FY
Y -> T | ε
F -> PZ
Z -> *Z | ε
P -> (E) | a | b

1. Please construct the SLR parsing table for G. Is the grammar SLR(1)?

(Non-Terminal) FIRST Set FOLLOW Set
E {(,a, b} {$, )}
T {(,a, b} {$, ), +}
X {ε, +} {$, )}
F {(,a, b} {$, (,), +, a, b}
Y {ε, (,a, b} {$, ), +}
P {(,a, b} {$, (,), *, +, a, b}
Z {ε, *} {$, (,), +, a, b}
阅读全文 »
0%