zxcve/vfs_userspace
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
User-Space Testing
###############################################################################
Build Using "make". If you are building on different host, then "make install" to scp it to VM.
Execute "./test.sh <levels>" to run the benchmark
The <levels> can vary from 1-5.
Each process creates 2 threads and each thread creates 2 processes.
This is done recursively till the height of the heirarchy tree is <levels>.
Example:
-------Snippet -----------
root@debian:/home/user# ./test.sh 1
Format: <process>(pid) {<thread>}(pid)
test(5023)─┬─test(5027)
├─test(5028)
├─test(5029)
├─test(5030)
├─{test}(5025)
└─{test}(5026)
------- XXXXX -----------
The above print is from pstree. Although it may seem confusing for threads, but the parent of all threads is still same.
Also signals for kernel thread only works if allow_signal(<signal_number>) is present in the thread code. By default most of the
kernel threads ignore the signals.
Also my tree hierarchy uses "pid" of kernel space which is "tid" in user space.
################################################################################
Kernel-Space Testing
################################################################################
Build Using "make". If you are building on different host, then "make install" to scp it to VM.
Command To mount:
1) mount -t project4 none <mount_point>
2) tree <mount_point>
The above command will take the current snapshot for the process hierarchy and create vfs
Example:
-------Snippet of tree output -----------
├── 5023
│ ├── 5023.status
│ └── signal
├── 5025
│ ├── 5025.status
│ ├── 5027
│ │ ├── 5027.status
│ │ └── signal
│ ├── 5028
│ │ ├── 5028.status
│ │ └── signal
│ └── signal
├── 5026
│ ├── 5026.status
│ ├── 5029
│ │ ├── 5029.status
│ │ └── signal
│ ├── 5030
│ │ ├── 5030.status
│ │ └── signal
│ └── signal
└── signal
------- XXXXX -----------
Comand to Send Signal
1) echo "10" > <signal_file>
Example:
echo "10" 4987/signal
-------Kernel Dmesg Log ------------
[ 6329.736812] Signal SIGUSR1<10> delivered PID<5023> TID<5026>
------- XXXXX -----------
-------User space Log ------------
SIGUSR1-> TID<5026> PID<5023>
------- XXXXX -----------
The above pid and tid are from user-space. This pid and tid maps to tgid and pid of kernel space respectively.
Command to Print Status
1) cat <status_file>
Example:
For a user process
cat 1.status
########## Status ###########
Virtual_Memory_Size: 28556 kB
Virtual_Memory_Peak: 29432 kB
Text_VM: 4640 kB
Lib_VM: 11088 kB
Data_VM: 1744 kB
Stack_VM: 136 kB
State: S (sleeping)
Type: USER_PROCESS
Cpu 3
Monotonic_Start_Time 24000000ns
Name: systemd
Stack_Pointer: 0xffff88007d3f8000
#############################
For a kernel thread
cat 2.status
########## Status ###########
State: S (sleeping)
Type: KERNEL_THREAD
Cpu 0
Monotonic_Start_Time 24000000ns
Name: kthreadd
Stack_Pointer: 0xffff88007c810000
#############################
For a user thread
cat 2140.status
########## Status ###########
Virtual_Memory_Size: 22768 kB
Virtual_Memory_Peak: 22768 kB
Text_VM: 16 kB
Lib_VM: 7568 kB
Data_VM: 16596 kB
Stack_VM: 136 kB
State: S (sleeping)
Type: USER_THREAD
Cpu 3
Monotonic_Start_Time 1099133445690ns
Name: test
Stack_Pointer: 0xffff88007b730000
#############################