Linux Kernel - modrpc/info GitHub Wiki
- ๋ฌธ์ :
- ๊ธฐ๊ณ๊ฐ ํ๋ ์ฃผ์ด์ ธ์๋ค. ํ๋ก์ธ์, ๋ฉ๋ชจ๋ฆฌ, ๋์คํฌ ์์คํ ์ด ์๋ค.
- ์ฆ, ์ด ๊ธฐ๊ณ๋ฅผ ์ฐ๋ ์ ์ผํ ๋ฐฉ๋ฒ์ ํ๋ก๊ทธ๋จ์ ๋ฉ๋ชจ๋ฆฌ์ ์ฌ๋ฆฌ๊ณ IP๋ฅผ ์ง์ ํด์ฃผ๋ ๋ฐฉ๋ฒ์ด๋ค. ํ๋ก์ธ์ค์ ์ปจํธ๋กค์ ์ํด์๋ Bios firmware๋ฅผ ํตํด time-0๋ถํฐ ์ฅ์ ์ํด์ผ ํ๋ค. -- ์์ฃผ ๊ธธ๋ค์ด๊ธฐ ํ๋ ๋ง์ ๊ธธ๋ค์ธ๋ค๊ณ ์๊ฐํ์.
- Multiprogramming:
- ํ๋ก๊ทธ๋จ๋ค ์ฌ๋ฟ์ด ํ๋ก์ธ์ ํ๋๋ฅผ ๊ณต์ ํ๊ฒ ํ๊ณ ์ถ๋ค. ์ด๋ฅผ ์ํด bookkeeping์ด ํ์ํ๋ค. context switch๋ฅผ ์ํด์ ์ํ๋ฅผ load/saveํด์ผ ํ๋ค. Load/save๋ ์ด๋์ ํ๋? ๋น์ฐํ memory์. ๋ ํ์ฌ ์ด์์๋ process๋ค์ ๋ํ ์ ๋ณด๋ฅผ process table์ ์ ์ฅ -- ์ญ์ ๋ฉ๋ชจ๋ฆฌ์.
- ์ด์์ ๋ฉ๋ชจ๋ฆฌ ์ฌ์ฉ์ meta-level์์ OS๊ฐ ์ฌ์ฉํ๋ ๋ฉ๋ชจ๋ฆฌ. ๊ทธ๋ฌ๋ ๊ฐ๋ณ ํ๋ก์ธ์ค๋ค๋ ์์ฒด์ ์ผ๋ก ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฌ์ฉํ ์ ์๋ค. ์ด๋ฅผ ์ํด, ํน๋ณํ function (malloc/free)๋ฅผ ๋ง๋ ๋ค.
- Protection/Service:
- ์ฌ์ค ํ๋ก์ธ์ ์ ์ฅ์์๋ kernel์ด๋ user-space program์ด๋ ์ฐจ์ด๊ฐ ์์๋ค. ์์ฆ์ protection์ ์ํ mechanism์ ํ๋ก์ธ์์์ ์ ๊ณต์ํ์ง๋ง (e.g. flag bit).
- ๋ง์ฝ user-program์ด low-level memory (OS-maintained space)์ ์ง์ ๊ฐ์ ์๊ฒ ํ๋ค๋ฉด ์จ๊ฐ๋ฌธ์ ๊ฐ ์๊ธด๋ค. Bad hacker๋ ๋งํ ๊ฒ๋ ์๊ณ , ์ ๋ํ ์ฌ์ฉ์๋ system์ ์ผ๋ง๋ ์ง ๋ง๊ฐ๋จ๋ฆด์ ์๋ค.
- ๋ฐ๋ผ์ "Service" -- Don't do it yourself -- I'll do it for you.
- Devices:
- ๋ ์์ ์ผ๋ก ๋์ํ๋ ์ธ๋ถ peripheral๋ค์ ์ด๋ป๊ฒ ์ ์ดํ ๊ฒ์ธ๊ฐ?
- ํ์คํ๋ access(R/W): File + File operations
- i386 programmer's manual: http://pdos.csail.mit.edu/6.828/2014/readings/i386/toc.htm
$ sudo usermod -a -G sudo cjeong
$ <change to bridged networking>
$ sudo vi /etc/network/interfaces
auto eth1
iface eth1 inet dhcp
$ sudo service networking restart
$ <REBOOT if failed to access network>
- Build kernel: https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel, https://help.ubuntu.com/community/Kernel/Compile
- clean: fakeroot debian/rules clean
- build: fakeroot debian/rules binary-headers binary-generic
- install: sudo dpkg -i linux*2.6.38-7.37*.deb
- in case of failure, do:
- sudo apt-get -f install
- sudo apt-get autoremove
- if not work delete cache file in /var/cache/*******
- in case of failure, do:
- reboot: sudo reboot
- Three module types: char module, block module, network module
- FreeBSD: ISA Devide Drivers
- ls /dev
- do 'ls -l': "c" are char devices, "b" are block devices
- cat /proc/devices: shows major device numbers
- scull0-3: global/persistent memory area
- scullpipe0-3: FIFO devices
- scullsingle, scullpriv, sculluid, scullwid:
-
signal (aka software interrupts): notification to a process that an event has occurred
- it is an interrupt in the sense, it allows to add reactive behavior through signal handler
- signal generated by:
- user process to be sent to another
- user process to be sent to itself
-
the kernel for a user process
- hardware exception: e.g. devide-by-zero, segfault
- Ctrl-C, Ctrl-Z
- software event: e.g. input became available on a file descriptor
- classes of signals:
- traditional/standard signals (numbered 1 ~ 31): used by the kernel to notify processes of events (numbered 1 to 31)
- realtime signals
- Signal is generated by some event
- Once generated, signal is later delivered to a process, which then takes some action in response to the signal.
- Between the time it's generated and the time it's delivered, a signal is said to be pending
- Normally, a pending signal is delivered to a process as soon is it next scheduled to run, or immediately if the process is already running
- However, we need to ensure that a segment of code is not interrupted by the delivery of signal.
- To do this, we can add a signl to the process's signal mask -- a set of signals whose delivery is currently blocked
- blocked signals, when generated, remains pending until it's unblocked (i.e. removed from signal mask) later
- two ways:
signal()
andsigaction()
-
sigaction
can do more thansignal
and is more portable; more recommended
-
#include <signal.h>
int sigaction(int signum, const struct sigaction *act,
struct sigaction *oldact);
struct sigaction {
void (*sa_handler)(int);
void (*sa_sigaction)(int, siginfo_t *, void *);
sigset_t sa_mask;
int sa_flags;
void (*sa_restorer)(void);
};
- signal delivery:

#include <signal.h>
int kill(pid_t pid, int sig);