Monday, January 17, 2011

Protocol Definition

We all know what protocol is. That is set of rules or guidelines to communicate between devices to exchange the information. But what are those basic guidelines. This post describes about the protocol basic guidelines.

Rules/guidelines are –

Discovery and Check:
  • We should know, whether node B is available or not
  • Once node B is discovered, we need to check regularly the availability of node B

Address:

  • Need to know the Node B’s address. Similarly from Node B to Node A address.

Language/Format:

  • Node B should understand, what Node A sent
  • Data start and end – Frame start and Frame end
  • Detect errors in data sent – Checksum and CRC

Control speed of Transmission:

  • Node B will have limited buffers. Hence need to control the speed of transmission.
  • Detect loss and etc.

Multiplexing:

  • Segregate the data of multiple application between Node A and Node B

Session:

  • Mechanism to organize the related data

Quality of Service (QoS):

  • Enable information exchange with specified bandwidth, losses, transmission latency, jitter (variance in latency)

But there are certain limitations to achieve QoS. There are

  • Limited bandwidth, but many flows are required – It can be resolved by multiplex flows and prioritize and allocate share.
  • Limited reliability, but perfection required – Resolved by Data Retransmission and Reliable Medium
  • Limited buffers, but need excessive transmission – Resolved by restricting the sender and discarding excess data.

So, now it is easy to understand any protocols using these guidelines :-)

Tuesday, January 11, 2011

Interview Questions - Linux Kernel Process Management

Process:A program (object code) in execution.
Also, includes set of resources such as open files, pending signals, one or more threads of execution, an address space, internal kernel data structures and data section containing global variables.

Process id:Each process has a unique id called pid, used by system for identification.

Process spawning:New process is created and loading the new image in process address space. In Linux, it is done by fork followed by exec system call.

Fork:Creates a new process called child and duplicates the resources (other than pid, ppid and pending signals) from parent process address space to the child process address space. It returns twice from the kernel. Once is the parent process and again in the new born child.

Copy-on-write:Creates a new process and shares the resources from Parent process until anything written to address space. Here child runs first. Best for process spawning.

Vfork:Creates a new process and share the resources (other than page table entries) from parent process. After child runs exec or exit, parent process begins. Here the problem is, if exec failed in child, then parent process will never get executed. Best for process spawning.

Process states – Current status of the process. There are 5 process states
Task Running – List of tasks in run queue
Task Interruptible – Tasks which are sleeping and waiting for the condition to occur. It will respond to signal or interrupts.
Task uninterruptible – Same as Task interruptible. But it won’t respond to signals or interrupts.
Task Zombie – Task are completed. But waiting for the wait call from the parent process
Task Stopped – Tasks explicitly stopped by signals such as SIGKILL, SIGSTOP

Process context:When a program executes a system call or triggers an exception, it enters into kernel space. At this point, Kernel is said to be “Executing on behalf of the process” and is in process context.

Threads:There is no concept of threads in Linux. Here threads are the normal processes which share the resources with other processes.

Kernel Threads:There are certain operations will be done in background. It can be done by Kernel threads. But kernel threads exist only in kernel space and no process address space (mm pointer is NULL).

Process Termination:Processes are terminated by exit system call or return from the main () program or any signal/exception received.
But it releases the process, but not the process descriptor and enters into zombie state.

Removal of Process descriptor:Parent process calls wait system call to child process to get the status and it removes the process descriptor.

Zombie process:When child process is completed, it enters into zombie state till parent process invokes wait system call to child process.

Orphan process:Parent process exits before child process terminated which puts child process in zombie state for ever and wasting system memory by holding process address space. This child process is called orphan process.

Process scheduling:Scheduler -> Kernel subsystem for selecting which process to run next.

Preemption:Process of suspending the running process and invoking the high priority process.

Scheduler policy:
I/O bound processes:
Process spends much of its time for submitting and waiting for an I/O. For example, Text editor.
- Low latency (Quick Response time) => High Priority
- short duration => Less timeslice value

Processor bound processes:Process spends much of its time for executing the program. For examples, video encoder.
- Not interactive process => Less priority
- Long duration => High Timeslice value

But some processes are both I/O bound and processor bound.

Process Timeslice:Amount of time the process to run until it is preempted.
Whenever the new child process is created, Half of the timeslice will be taken from parent process.
Whenever the timeslice of process expired, it will be recalculated.

Nice value – Priority of the process. It ranges from -19 to 20(default value is 0). Larger nice value corresponds to Low priority and Lower nice value for High priority.

Runqueue:Each processor will have runqueue which contains the list of all runnable process.

Waitqueue:Processes that are waiting for an external event to be occurred will be placed in waitqueue. As soon as the condition occurs, the process brings back to run queue for execution.

Init process:Invoked at the end of boot process and its Pid value is 1. Created statically by init_task, where as all other processes are created dynamically.

Storage Area Network (SAN) Basics

SAN:Storage Area Network – It interconnects different types of storage devices (such as disk arrays, Tape drives) with the servers, as if storage devices are locally attached to the servers.
Access - Block Level

NAS:Network Attached Storage – It is a file-level computer data storage connected to a network providing data access to heterogeneous clients.
Access - File Level

DAS:Direct Attached Storage – A storage device directly attached to the server without the storage network.
Access - Block Level

Redundant Array of Independent Disks (RAID):Redundant – An extra “COPY” of data
Array – Number of disks together

Note: Parity is calculated using Exclusive OR (XOR).

Hardware Raid Vs Software Raid:



LUN: Logical Unit Number – Unique identification number of a SCSI device logical unit.

Zoning:Process that partitioning fabric (switch) into smaller groups for adding security.
Each hosts connected to the SAN should have the allowed access to controlled subset of LUNs.
Port Zoning:It uses physical ports to define security zones.

WWN Zoning:It uses name server in the switch to either allow or block based on the WWN.

Lun Masking:Process that makes LUN available to some hosts and unavailable to other hosts.

FC SAN Topologies:
Point to Point:
It is the simplest topology which allows the host and storage connect directly.

Arbitrated Loop:· Devices are connected in a one way loop fashion in a ring topology.
· One node acts as a transmitter and next node acts as a receiver.
· A maximum supported storage device is 127.

Switched Fabric:Storage devices are connected to each other via switches.

WWN:8 byte(64 bit) number. Hardcoded into a fibre channel HBA, used for identifying individual port in fabric.
First 3 bytes number purchased from IEEE OUI(Organizationally Unique Identifier) and the rest supplied by the vendor.

WWNN and WWPN:WWPN -> Assigned to Port
WWNN -> Assigned to Node (endpoint or device). Different WWPN can have the same WWNN on the network.

Multipath:In a SAN environment, each LUNs are accessed through multiple paths, as the storage controller and HBA having multiple ports.