- : enable the option
+ : disable the option
Example:
set -o errexit
equals to
set -e
Control operators:
& && ( ) \n ;; ; | ||
Redirection operators:
< > << >> <> <& >& <<- >|
Single Quotes: preserve the literal meaning of all the chars except '
Double Quotes: preserve the literal meaning of all the chars except $ ` \
Backslash: preserve the literal meaning of all the chars except \n
Reserved Words:
! { } case do done elif else esac fi for if then until while
Aliases:
Commands:
Simple Commands Order:
Leading words name=value; Word Expansions; Redirection
Redirections:
[n]> file
[n]>| file
[n]>> file
[n]< file
[n]<> file
[n]<&n2
[n1]<&-
[n1]>&n2
[n]>&-
Search and Execution:
shell functions,
built-in commands,
normal programs
Path Search for normal programs:
shell function, built-in, then PATH
Command Exit Status:
zero succeed
non-zero failure
128+signo terminated by a signal
Complex Commands:
simple command
pipeline
list or compound-list
compound command
function definition
Pipelines:
[!] command1 [| command2 ...]
Background Commands:
command1 & [command2 & ...]
Lists:
Short-Circuit List Operators:
&& ||
Flow-Control Constructs:
if list
then list
else iist
fi
while list
do list
done
for variable [in word ...]
do list
fone
break [num]
continue [num]
case word in
pattern) list ;;
...
esac
Grouping Commands Together:
(list)
or
{ list; }
Functions
name ( ) command
local variable
return [exit status]
Variables and Parameters:
name=value
Positional Parameters:
$0 $1 ...
Special Parameters:
$*: positional parameters starting from one
$@: positional parameters starting from one
$#: number of positional parameters
$?: the exit status of the most recent pipeline
$-: the current option flags
$$: the process id of the invoked shell
$!: the process ID of the most recent background command
$0: name of the shell or shell script
Word Expansions:
Tilde Expansion, Parameter Expansion, Command Substitution,
Arithmetic Expansion, Quote removal
Tilde Expansion:
~/.tools/list
/usr/name/.tool/list
Parameter Expansion:
${expression}
${parameter:-word} : Use default value
${parameter:=word} : Assign default value
${parameter:?[word]} :Indicate Error if Null or Unset
${parameter:+word} : Use Alternate Value
${#parameter} : string length
${parameter%word} : Remove smallest suffix pattern
${parameter%%word} : Remove largest suffix pattern
${parameter#word} : Remove smallest prefix pattern
${parameter##word} : Remove largest prefix pattern
Command Substitution:
$(command) or
`command`
Arithmetic Expansion:
$((expression))
While Space Splitting:
Pathname Expansion:
Shell Patterns:
! * ? [
*: any string of chars
?: any single char
[: introduce a char class
]: end a char of class
Built-in Commands:
: null cmmand that return a 0 exit value
. file: file is read and excuted
[ : built-in equivalent of test
alias [name[=string] ...] :
bg [job ...': background
builtin cmd: execute the specified built0in command
bind:
cd directory:
chdir:
command [-p]
command [-v]
echo [-e | -n] [string ...]
eval string ...
exec [command [arg ...]]
exit [exitstatus]
export name ...
export [-p]
false
fc [-e editor]
fc -l
fc -s
fg [job]
getopts optstring var
hash [-rv] [command ...]
jobid [job]
jobs [-lps]
local:
pwd [-L | -P]
read [-p prompt] [-t timeout] [-er] variable
readonly [-p] [name]
return [exitstatus]
set [-/+abCE..]
setvar variable value
shift [n]
test
times:
trap [action] signal
trap -l
true
type [name ...]
unlimit
unmask
unalias
unset
wait [job]
From Bits to Packets
Just share personal understanding on network technology from bits to packets
Tuesday, July 29, 2014
Wednesday, February 26, 2014
Linux Storage Terminology
AFS: Andrew distributed file system
ATA: Advanced Technology Attachment
ATAoE: ATA over Ethernet
BTRFS: Butter FS
CAS: content-addressable storage
Ceph:
CIFS: Common Internet File System
CRC: cyclic redundancy check
DAP: Data Access Protocol
DAS: Direct-attached storage
DIF: data integrity field
exofs:Extended Object File System
ext3: third extended file system
ext4: fourth extended file system
FC: Fibre Channel
FCoE: Fibre Channel over Ethernet
FCS: fixed-content storage
FUSE: Filesystem in Userspace
JFFS2: Journaling Flash File System version 2
GPFS: General Parallel File System
HPC: high-performance computing
IDE: Integrated Drive Electronics
iSCSI: Internet SCSI
ISO: nternational Organization for Standardization
LBA: logical block addressing
LUN: Logical Unit Number
Lustre: Linux clUSTER
LVM: Logical Volume Manage
NAS: Network-attached storage
NFS: Network File System
OSD: Object Storage Device
pNFS: Parallel NFS
RAID: redundant array of independent disks
RDMA: remote direct memory access
RPC: remote procedure call
SAN: Storage area networks
SATA: Serial ATA
SAS: Serial attached SCSI
SCSI: Small Computer System Interface
SMB: Server Message Block
SRP: SCSI RDMA Protocol
SSA: Serial Storage Architecture
SSD: solid-state disk
eSATA: external SATA
UBIFS: Unsorted Block Image File System
UDP: Universal Datagram Protocol
USB: Universal Serial Bus
VFS: virtual file system switch
XDR: external data representation
xHCI: Extensible Host Controller Interface
XIP: Execute-in-place
YAFFS2: Yet Another Flash File System version 2
ZFS: Zettabyte File System
ATA: Advanced Technology Attachment
ATAoE: ATA over Ethernet
BTRFS: Butter FS
CAS: content-addressable storage
Ceph:
CIFS: Common Internet File System
CRC: cyclic redundancy check
DAP: Data Access Protocol
DAS: Direct-attached storage
DIF: data integrity field
exofs:Extended Object File System
ext3: third extended file system
ext4: fourth extended file system
FC: Fibre Channel
FCoE: Fibre Channel over Ethernet
FCS: fixed-content storage
FUSE: Filesystem in Userspace
JFFS2: Journaling Flash File System version 2
GPFS: General Parallel File System
HPC: high-performance computing
IDE: Integrated Drive Electronics
iSCSI: Internet SCSI
ISO: nternational Organization for Standardization
LBA: logical block addressing
LUN: Logical Unit Number
Lustre: Linux clUSTER
LVM: Logical Volume Manage
NAS: Network-attached storage
NFS: Network File System
OSD: Object Storage Device
pNFS: Parallel NFS
RAID: redundant array of independent disks
RDMA: remote direct memory access
RPC: remote procedure call
SAN: Storage area networks
SATA: Serial ATA
SAS: Serial attached SCSI
SCSI: Small Computer System Interface
SMB: Server Message Block
SRP: SCSI RDMA Protocol
SSA: Serial Storage Architecture
SSD: solid-state disk
eSATA: external SATA
UBIFS: Unsorted Block Image File System
UDP: Universal Datagram Protocol
USB: Universal Serial Bus
VFS: virtual file system switch
XDR: external data representation
xHCI: Extensible Host Controller Interface
XIP: Execute-in-place
YAFFS2: Yet Another Flash File System version 2
ZFS: Zettabyte File System
Tuesday, February 25, 2014
GPIO Interrupts Routing in X86
Interrupt routing on X86 is very complicated.
On X86, the 1s 16 GPIO pins can be configured as interrupt.
The routing path for GPIO interrupt is:
GPIO-->ACPI(GPE)-->IRQ9
error gpe02 gpe0A gpe12 gpe1A gpe22 gpe2A gpe32 gpe3A
ff_gbl_lock gpe03 gpe0B gpe13 gpe1B gpe23 gpe2B gpe33 gpe3B
ff_pmtimer gpe04 gpe0C gpe14 gpe1C gpe24 gpe2C gpe34 gpe3C
ff_pwr_btn gpe05 gpe0D gpe15 gpe1D gpe25 gpe2D gpe35 gpe3D
ff_rt_clk gpe06 gpe0E gpe16 gpe1E gpe26 gpe2E gpe36 gpe3E
ff_slp_btn gpe07 gpe0F gpe17 gpe1F gpe27 gpe2F gpe37 gpe3F
gpe00 gpe08 gpe10 gpe18 gpe20 gpe28 gpe30 gpe38 gpe_all
gpe01 gpe09 gpe11 gpe19 gpe21 gpe29 gpe31 gpe39 sci
On X86, the 1s 16 GPIO pins can be configured as interrupt.
The routing path for GPIO interrupt is:
GPIO-->ACPI(GPE)-->IRQ9
Linux# ls /sys/firmware/acpi/interrupts/
error gpe02 gpe0A gpe12 gpe1A gpe22 gpe2A gpe32 gpe3A
ff_gbl_lock gpe03 gpe0B gpe13 gpe1B gpe23 gpe2B gpe33 gpe3B
ff_pmtimer gpe04 gpe0C gpe14 gpe1C gpe24 gpe2C gpe34 gpe3C
ff_pwr_btn gpe05 gpe0D gpe15 gpe1D gpe25 gpe2D gpe35 gpe3D
ff_rt_clk gpe06 gpe0E gpe16 gpe1E gpe26 gpe2E gpe36 gpe3E
ff_slp_btn gpe07 gpe0F gpe17 gpe1F gpe27 gpe2F gpe37 gpe3F
gpe00 gpe08 gpe10 gpe18 gpe20 gpe28 gpe30 gpe38 gpe_all
gpe01 gpe09 gpe11 gpe19 gpe21 gpe29 gpe31 gpe39 sci
Reading Materials:
PCI Interrupts
PCI Interrupts for x86 Machines under FreeBSD
User Space Device Driver
Thursday, October 3, 2013
Wednesday, October 2, 2013
Linux Scheduler
See link:
3 Linux Scheduling Policies:
Linux scheduler queues:
- http://www.ibm.com/developerworks/linux/library/l-scheduler/
- http://en.wikipedia.org/wiki/Completely_Fair_Scheduler
- http://www.ibm.com/developerworks/linux/library/l-completely-fair-scheduler/
3 Linux Scheduling Policies:
- SCHED_OTHER/SCHED_NORMAL Time-based policy with time slices
- SCHED_FIFO Priority-based policy
- SCHED_RR Priority-based policy with time slices
Linux scheduler queues:
- runqueue
- wait_queue or
- red-black tree
- TASK_RUNNING(runqueue)
- TASK_INTERRUPTIBLE(wait_queue)
- TASK_UNINTERRUPTIBLE(wait_queue)
- TASK_STOPPED
- TASK_ZOMBIE
- O(N)
- O(1)
- Completely Fair Scheduler (CFS)
Threads vs Process on Linux
See the following links:
http://www.samba.org/~tridge/talks/threads.pdf
http://www.mulix.org/lectures/kernel_workshop_mar_2004/things.pdf
http://en.wikipedia.org/wiki/Thread_%28computing%29
Thread has its own stack, its own register set/context. User space threads or kernel space threads?
The context of a thread is the register set, including the stack pointer.
Context switch between threads includes saving registers, restore registers only, while MMU context(Page table) & TLB stays.
Process has its own virtual address space, and has at least one thread; all threads within it share the parent process's virtual address space.
The context of a process includes state, priority, signal info, process id, and a pointer to thread.
Context switch between processes needs a switch of virtual address space, including cache and TLB flushing, MMU context switching, and thread switching.
Both thread and process 's creation in user space went to the same system call(clone) in the kernel.
Linux implements 1:1 model.
Keep in mind, TLB and MMU context is per-CPU on Linux.
http://www.samba.org/~tridge/talks/threads.pdf
http://www.mulix.org/lectures/kernel_workshop_mar_2004/things.pdf
http://en.wikipedia.org/wiki/Thread_%28computing%29
Thread has its own stack, its own register set/context. User space threads or kernel space threads?
The context of a thread is the register set, including the stack pointer.
Context switch between threads includes saving registers, restore registers only, while MMU context(Page table) & TLB stays.
Process has its own virtual address space, and has at least one thread; all threads within it share the parent process's virtual address space.
The context of a process includes state, priority, signal info, process id, and a pointer to thread.
Context switch between processes needs a switch of virtual address space, including cache and TLB flushing, MMU context switching, and thread switching.
Both thread and process 's creation in user space went to the same system call(clone) in the kernel.
Linux implements 1:1 model.
Keep in mind, TLB and MMU context is per-CPU on Linux.
Tuesday, October 1, 2013
vmlinux vs vmlinuz vs (b)zImage vs uImage
See the wiki link
- vmlinux -- compiled from source
- vmlinuz -- compressed from vmlinux
- (b)zImage -- final binary image includes: bootloader, uncompress vmlinuz, load vmlinux, ramdisk
- uImage -- final image for U-boot
- # readelf -h /boot/vmlinuz-2.6.18-238.el5
ELF Header:
Magic: 7f 45 4c 46 02 01 01 ff eb 3d 00 00 00 00 00 00
Class: ELF64
Data: 2's complement, little endian
Version: 1 (current)
OS/ABI: Standalone App
ABI Version: 235
Type: DYN (Shared object file)
Machine: Advanced Micro Devices X86-64
Version: 0x1
Entry point address: 0x100
Start of program headers: 80 (bytes into file)
Start of section headers: 0 (bytes into file)
Flags: 0x0
Size of this header: 64 (bytes)
Size of program headers: 56 (bytes)
Number of program headers: 2
Size of section headers: 64 (bytes)
Number of section headers: 0
Section header string table index: 0 - # dd if=uImage of=zImage bs=64 skip=1
42667+1 records in
42667+1 records out - # hexdump -v uImage.header
0000000 0527 5619 4713 7f79 2f4d e379 2900 ceaa
0000010 0000 0000 0000 0000 b9d8 534e 6ab9 e05b
0000020 a06b ec5b 1885 0898 80f2 6f74 0705 0102
0000030 694c 756e 2d78 2e32 2e36 3031 6d5f 6c76
Subscribe to:
Posts (Atom)