전체 페이지뷰

2013년 1월 21일 월요일

Tcpip in Linux ch1

When an application sends out TCP data, the application’s associated kernel thread may return after transmitting data completely. TCP data may be queued at different levels such as socket’s send queue, device queue (TOS), and CPU output queue. This data are transmitted asynchronously by kernel timers or Tx softIRQ.
TCP data are processed in two steps: The packet is queued to CPU’s input queue and is processed completely later on by Rx softIRQ. SoftIRQ may execute in interrupt context or may also be executed by a kernel thread.
A network-specific kernel code can be found under net directory of the kernel source tree. An IPv4-specific code can be found under ipv4 subdirectory of net. A packet-scheduling-specific code can be found under sched subdirectory of net directory.
Linux kernel 2.4 and below are non-preemptive kernels; as a result, they are not suitable for real-time applications that require low latencies and timeliness for execution.
A system call is implemented by raising soft interrupt int 0x80. This interrupt switches from user to kernel mode and switches processor privilege to super-user mode where kernel code and data structure can be accessed on behalf of applica- tion. A kernel searches sys_call_table to execute systemcall. sys_call_table maps a system call number to systemcall callback routines.
Each Linux process has a kernel thread and kernel mode stack. A processor switches to kernel mode stack when the process enters a kernel via systemcall. The kernel thread is a scheduling entity for the kernel. The pthread library on Linux creates an LWP for the process. These LWPs share resources with the parent process including process address space. All the lightweight processes (LWP) as scheduling entities inside the kernel.
Threads created in the kernel cannot be preempted unless they yield on their own. Kernel threads can be seen with ps command and usually start with the letter k, like kflushd.
Linux implements atomic operations, semaphores, and spin locks as a synchro- nization mechanism. Spin locks are the most extensively used synchronization mechanism to synchronize data access between two CPUs, kernel control path and softIRQs, kernels, and interrupts and have a performance edge over semaphores.
Applications communicate over the TCP/IP protocol by way of client–server technique. These programs use a socket interface to open connection and commu- nicate over the socket using different I/O interfaces provided to the application programs.
TCP is a connection-oriented protocol that maintains state. To start a connec- tion, TCP completes a three-way handshake and attains an established state. TCP closes connection cleanly by way of a four-way handshake. It maintains state at each step of connection initiation and connection closure stages and defines action for each state.

댓글 없음:

댓글 쓰기