OS ASSIGNMENT
- GAJJAR PREMAL
B
How to get around in the source code tree?
The kernel source is in /usr/src/linux/ directory.
There are several ways to surf this huge repository:
A. cscope (man cscope)
Browse .c or .h or .l
file using cscope
ex. video.h
you can see the
file contain and
list of file
similer to this
name.
B. ctags (man ctags)
ctags – Generate tag files for source code
ability to jump from the current source file to definations of
function and structures in other file.
Go to -
_Open both that file
_Contain list of index file (Source file ) or entry
in text form.
_and you can directly to the file or line wich
defines the name.
C. find + grep + less
find - search for files in a directory hierarchy
Here_
find – search for find in directry
file_name – name of the file
grep – print lines matching a pattern
less – show all lines
D. global (man global)
global - print the locations of specified object.
Your Task: (The objective of this task is to get an idea about where and how to
view the Linux source code.
You are NOT required to understand the code at this moment.)
find file_name + grep + less
1. Find the following "famous" code, and tell me.
why they are "famous".
(1) start_kernel();
start_kernel().
start_kernel() then performs the majority of system setup like interrupts, the rest of
memory management, device initialization, drivers, etc.
before spawning separately, the idle process and scheduler, and the Init process
( executed in user space).
(2) init();
location - /etc/init
init()
process executes scripts as needed that set up all non-operating system services
and structure in order to allow a user environment to be created then presents the
user with a login screen.
(3) struct task_struct;
code - locate struct task_struct
location -
/usr/src/linux-headers-3.5.0-17/include/linux/sched .h/structtask_struct
struct task_struct;
• each task_struct data structure describe a process or task in the system.
• The max. Number of process which can be created on linux is limited only by
amount of physical memory present.
• Set of process on the linux system is represent as collection of struct
task_struct.
1. As a hash table
2. As a circular
(4) struct inode;
code – locate struct inode | less
location- linux-headers...generic/include/config/anon/inodes.h
struct inode
• the VFS inode data structure hold information about a file or directory on disk.
• Inode contains metadata of file.
• Its serial number, protection (mode) owner, size, dates of last access and
modification.
• also points to the superblock of the filesystem.
• the file is in, the methods for this file, and its name.
(5) struct file;
code – locate fs.h | more
location - /usr/src/linux-headers..../include/linux/fs.h
struct file;
• 2nd most important data structure used in device driver (not ever open file in
system)
• it is a kernel structure that never appears in user programs.
• In kernel each device is represented in kernel by file structure, which defined
in linux/fs.h
(6) fork();
code – man fork
fork();
• creat a child process
(7) include/asm−generic/unistd.h
• it is the name of header file that provides access to the POSIX operating
system API.
(8) arch/ia64/kernel/entry.S
• entry point to all system calls which initializes the treatment of exceptions.
(9) kernel/printk.c
• printk is equivalent of c standard function printf.
• whenever you want to find out what's going on inside the kernel, a good way
to start is by putting printk's in stategic places.
- GAJJAR PREMAL
B
How to get around in the source code tree?
The kernel source is in /usr/src/linux/ directory.
There are several ways to surf this huge repository:
A. cscope (man cscope)
Browse .c or .h or .l
file using cscope
ex. video.h
you can see the
file contain and
list of file
similer to this
name.
B. ctags (man ctags)
ctags – Generate tag files for source code
ability to jump from the current source file to definations of
function and structures in other file.
Go to -
_Open both that file
_Contain list of index file (Source file ) or entry
in text form.
_and you can directly to the file or line wich
defines the name.
C. find + grep + less
find - search for files in a directory hierarchy
Here_
find – search for find in directry
file_name – name of the file
grep – print lines matching a pattern
less – show all lines
D. global (man global)
global - print the locations of specified object.
Your Task: (The objective of this task is to get an idea about where and how to
view the Linux source code.
You are NOT required to understand the code at this moment.)
find file_name + grep + less
1. Find the following "famous" code, and tell me.
why they are "famous".
(1) start_kernel();
start_kernel().
start_kernel() then performs the majority of system setup like interrupts, the rest of
memory management, device initialization, drivers, etc.
before spawning separately, the idle process and scheduler, and the Init process
( executed in user space).
(2) init();
location - /etc/init
init()
process executes scripts as needed that set up all non-operating system services
and structure in order to allow a user environment to be created then presents the
user with a login screen.
(3) struct task_struct;
code - locate struct task_struct
location -
/usr/src/linux-headers-3.5.0-17/include/linux/sched .h/structtask_struct
struct task_struct;
• each task_struct data structure describe a process or task in the system.
• The max. Number of process which can be created on linux is limited only by
amount of physical memory present.
• Set of process on the linux system is represent as collection of struct
task_struct.
1. As a hash table
2. As a circular
(4) struct inode;
code – locate struct inode | less
location- linux-headers...generic/include/config/anon/inodes.h
struct inode
• the VFS inode data structure hold information about a file or directory on disk.
• Inode contains metadata of file.
• Its serial number, protection (mode) owner, size, dates of last access and
modification.
• also points to the superblock of the filesystem.
• the file is in, the methods for this file, and its name.
(5) struct file;
code – locate fs.h | more
location - /usr/src/linux-headers..../include/linux/fs.h
struct file;
• 2nd most important data structure used in device driver (not ever open file in
system)
• it is a kernel structure that never appears in user programs.
• In kernel each device is represented in kernel by file structure, which defined
in linux/fs.h
(6) fork();
code – man fork
fork();
• creat a child process
(7) include/asm−generic/unistd.h
• it is the name of header file that provides access to the POSIX operating
system API.
(8) arch/ia64/kernel/entry.S
• entry point to all system calls which initializes the treatment of exceptions.
(9) kernel/printk.c
• printk is equivalent of c standard function printf.
• whenever you want to find out what's going on inside the kernel, a good way
to start is by putting printk's in stategic places.
No comments:
Post a Comment