-S option . listing directory contents sorted by file size

GNU command

$ls -l -Gg
total 124
-rwxr-xr-x 1 54161 Dec 12 18:32 bp
-rw-r--r-- 1  8917 Sep 22  2006 cfg.c
-rw-r--r-- 1  1638 Sep 22  2006 cfg.h
drwxr-xr-x 2  4096 Oct 26 17:43 CVS
drwxr-xr-x 3  4096 Oct 26 00:48 gtk
-rw-r--r-- 1   104 Oct 26 00:49 Makefile
-rw-r--r-- 1   718 Dec 12 18:33 sample.cfg
-rw-r--r-- 1 32385 Oct 26 17:43 simpleproxy.c


$ls -l -Gg -S 

total 124
-rwxr-xr-x 1 54161 Dec 12 18:32 bp
-rw-r--r-- 1 32385 Oct 26 17:43 simpleproxy.c
-rw-r--r-- 1  8917 Sep 22  2006 cfg.c
drwxr-xr-x 2  4096 Oct 26 17:43 CVS
drwxr-xr-x 3  4096 Oct 26 00:48 gtk
-rw-r--r-- 1  1638 Sep 22  2006 cfg.h
-rw-r--r-- 1   718 Dec 12 18:33 sample.cfg
-rw-r--r-- 1   104 Oct 26 00:49 Makefile
$


GNU related Explanation

-S     sort by file size

ls (-t option) sort by modification time

GNU command

$ls -l
total 40
drwxr-xr-x  3 jeffrin jeffrin 4096 Aug 18 20:16 beautifulwork
drwxr-xr-x  5 jeffrin jeffrin 4096 Aug 18 20:16 books
drwxr-xr-x  2 jeffrin jeffrin 4096 Aug 18 20:16 bugs-general
drwxr-xr-x  2 jeffrin jeffrin 4096 Oct 13 20:27 config-files
drwxr-xr-x  3 jeffrin jeffrin 4096 Aug 24 22:03 debian-howtos
drwxr-xr-x  2 jeffrin jeffrin 4096 Oct 20 21:59 Docs
drwxr-xr-x  3 jeffrin jeffrin 4096 Oct 19 20:15 https:
drwxr-xr-x  6 jeffrin jeffrin 4096 Oct 21 01:00 language
drwxr-xr-x 10 jeffrin jeffrin 4096 Aug 18 20:16 linux
drwxr-xr-x  6 jeffrin jeffrin 4096 Aug 18 20:16 ovlfose
-rw-r--r--  1 jeffrin jeffrin    0 Aug 18 20:16 README
$ls -l -t
total 40
drwxr-xr-x  6 jeffrin jeffrin 4096 Oct 21 01:00 language
drwxr-xr-x  2 jeffrin jeffrin 4096 Oct 20 21:59 Docs
drwxr-xr-x  3 jeffrin jeffrin 4096 Oct 19 20:15 https:
drwxr-xr-x  2 jeffrin jeffrin 4096 Oct 13 20:27 config-files
drwxr-xr-x  3 jeffrin jeffrin 4096 Aug 24 22:03 debian-howtos
drwxr-xr-x  3 jeffrin jeffrin 4096 Aug 18 20:16 beautifulwork
drwxr-xr-x  5 jeffrin jeffrin 4096 Aug 18 20:16 books
drwxr-xr-x  2 jeffrin jeffrin 4096 Aug 18 20:16 bugs-general
drwxr-xr-x 10 jeffrin jeffrin 4096 Aug 18 20:16 linux
drwxr-xr-x  6 jeffrin jeffrin 4096 Aug 18 20:16 ovlfose
-rw-r--r--  1 jeffrin jeffrin    0 Aug 18 20:16 README
$

GNU Explanation

-t     sort by modification time, newest first

__generic_file_aio_write – write data to a file

1. __generic_file_aio_write – write data to a file

 ssize_t __generic_file_aio_write(struct kiocb * iocb, const struct iovec * iov, unsigned long nr_segs, loff_t * ppos);

iocb    IO state structure (file, offset, etc.)

iov     vector with data to write

nr_segs number of segments in the vector

ppos    position where to write


2. Classroom

Asynchronous I/O,  or non-blocking I/O,  is a form  of input/output
processing  that permits  other processing  to continue  before the
transmission has finished.  Input  and output (I/O) operations on a
computer  can  be extremely  slow  compared  to  the processing  of
data. An  I/O device can  incorporate mechanical devices  that must
physically move,  such as  a hard drive  seeking a trackto  read or
write; this is often orders  of magnitude slower than the switching
of  electric current.  For example,  during a  disk  operation that
takes ten milliseconds  to perform, a processor that  is clocked at
one     gigahertz    could     have    performed     ten    million
instruction-processing cycles.   A simple approach to  I/O would be
to start the  access and then wait for it to  complete. But such an
approach (called  synchronous I/O or blocking I/O)  would block the
progress  of a  program  while the  communication  is in  progress,
leaving  system  resources idle.  When  a  program  makes many  I/O
operations, this means  that the processor can spend  almost all of
its   time   idle  waiting   for   I/O   operations  to   complete.
Alternatively, it is possible,  but more complicated to predict, to
start the  communication and then perform processing  that does not
require  that  the  I/O  has  completed. This  approach  is  called
asynchronous input/output.  Any task  that actually depends  on the
I/O having completed (this includes both using the input values and
critical operations that claim to assure that a write operation has
been  completed) still  needs  to  wait for  the  I/O operation  to
complete, and thus is still blocked, but other processing that does
not have a dependency on the I/O operation can continue.

source : http://en.wikipedia.org/wiki/Asynchronous_I/O

readelf (-a option) Displays information about ELF files

UNIX Command

$cat hello.c
#include
main()
{
int d;
scanf("%d",d);
printf("%d",d);
}
$gcc hello.c
$ulimit -c unlimited
$./a.out
3
Segmentation fault (core dumped)
$readelf -s core
$readelf -a core
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              CORE (Core file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          64 (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:         17
  Size of section headers:           0 (bytes)
  Number of section headers:         0
  Section header string table index: 0

There are no sections in this file.

There are no sections to group in this file.

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  NOTE           0x00000000000003f8 0x0000000000000000 0x0000000000000000
                 0x0000000000000558 0x0000000000000000         0
  LOAD           0x0000000000001000 0x0000000000400000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  R E    1000
  LOAD           0x0000000000002000 0x0000000000600000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  RW     1000
  LOAD           0x0000000000003000 0x00007f1e480c7000 0x0000000000000000
                 0x0000000000001000 0x000000000017a000  R E    1000
  LOAD           0x0000000000004000 0x00007f1e48241000 0x0000000000000000
                 0x0000000000000000 0x0000000000200000         1000
  LOAD           0x0000000000004000 0x00007f1e48441000 0x0000000000000000
                 0x0000000000004000 0x0000000000004000  R      1000
  LOAD           0x0000000000008000 0x00007f1e48445000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  RW     1000
  LOAD           0x0000000000009000 0x00007f1e48446000 0x0000000000000000
                 0x0000000000005000 0x0000000000005000  RW     1000
  LOAD           0x000000000000e000 0x00007f1e4844b000 0x0000000000000000
                 0x0000000000001000 0x000000000001f000  R E    1000
  LOAD           0x000000000000f000 0x00007f1e48643000 0x0000000000000000
                 0x0000000000003000 0x0000000000003000  RW     1000
  LOAD           0x0000000000012000 0x00007f1e48667000 0x0000000000000000
                 0x0000000000003000 0x0000000000003000  RW     1000
  LOAD           0x0000000000015000 0x00007f1e4866a000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  R      1000
  LOAD           0x0000000000016000 0x00007f1e4866b000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  RW     1000
  LOAD           0x0000000000017000 0x00007f1e4866c000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  RW     1000
  LOAD           0x0000000000018000 0x00007fff27f53000 0x0000000000000000
                 0x0000000000022000 0x0000000000022000  RW     1000
  LOAD           0x000000000003a000 0x00007fff27fff000 0x0000000000000000
                 0x0000000000001000 0x0000000000001000  R E    1000
  LOAD           0x000000000003b000 0xffffffffff600000 0x0000000000000000
                 0x0000000000000000 0x0000000000001000  R E    1000

There is no dynamic section in this file.

There are no relocations in this file.

There are no unwind sections in this file.

No version information found in this file.

Notes at offset 0x000003f8 with length 0x00000558:
  Owner                 Data size	Description
  CORE                 0x00000150	NT_PRSTATUS (prstatus structure)
  CORE                 0x00000088	NT_PRPSINFO (prpsinfo structure)
  CORE                 0x00000130	NT_AUXV (auxiliary vector)
  CORE                 0x00000200	NT_FPREGSET (floating point registers)
$

UNIX Explanation

readelf displays  information about one  or more ELF  format object
files.  The options control what particular information to display.
elffile... are the object files  to be examined.  32-bit and 64-bit
ELF  files are  supported, as  are archives  containing  ELF files.
This program  performs a  similar function to  objdump but  it goes
into more detail and it exists independently of the BFD library, so
if there is a bug in BFD then readelf will not be affected.

vm_insert_page – insert single page into user vma

1. vm_insert_page - insert single page into user vma


int vm_insert_page(struct vm_area_struct * vma, unsigned long addr, struct page * page);

vma  user vma to map to

addr  target user address of this page

page  source kernel page


2. Classroom


The  virtual  memory  area   (VMA)  is  the  kernel  data
structure used to manage  distinct regions of a process's
address space.  A VMA represents a  homogeneous region in
the virtual  memory of a  process: a contiguous  range of
virtual addresses that have the same permission flags and
are backed  up by the same  object (a file,  say, or swap
space).  It  corresponds  loosely  to the  concept  of  a
"segment," although  it is better described  as "a memory
object  with its  own properties."  The memory  map  of a
process is made up of (at least) the following areas:

An area for the program's executable code (often called text)

Multiple areas for data, including initialized data (that
which has  an explicitly assigned value  at the beginning
of  execution),  uninitialized  data  (BSS),[3]  and  the
program stack

[3]  The name  BSS  is  a historical  relic  from an  old
assembly operator meaning  "block started by symbol." The
BSS segment of executable files isn't stored on disk, and
the kernel maps the zero page to the BSS address range.

One area for each active memory mapping

related source: http://www.makelinux.net/ldd3/chp-15-sect-1

grep ( -c option )

UNIX Command

$grep -c pack  resume.txt
0
$grep -c Linux  resume.txt
9
$grep -c Lin  resume.txt
9
$grep -c Li  resume.txt
9
$grep -c L  resume.txt
15
$grep -c engineer  resume.txt
2
$grep -c 1976  resume.txt
1
$grep -c GNU  resume.txt
5
$

UNIX Explanation For (grep -c)

Suppress normal output; instead print a count of matching lines for
each input  file.  With the -v, --invert-match  option (see below),
count non-matching lines.  (-c is specified by POSIX.)

maps memory maps to executables and library files

1.Classroom

maps   Memory maps to executables and library files

Get The Hang

$sudo cat /proc/971/maps
00400000-00408000 r-xp 00000000 08:01 7422174                            /sbin/syslogd
00607000-00608000 rw-p 00007000 08:01 7422174                            /sbin/syslogd
00608000-00609000 rw-p 00000000 00:00 0
01429000-0144a000 rw-p 00000000 00:00 0                                  [heap]
7fd360fa5000-7fd360fb0000 r-xp 00000000 08:01 1466895                    /lib/x86_64-linux-gnu/libnss_files-2.13.so
7fd360fb0000-7fd3611af000 ---p 0000b000 08:01 1466895                    /lib/x86_64-linux-gnu/libnss_files-2.13.so
7fd3611af000-7fd3611b0000 r--p 0000a000 08:01 1466895                    /lib/x86_64-linux-gnu/libnss_files-2.13.so
7fd3611b0000-7fd3611b1000 rw-p 0000b000 08:01 1466895                    /lib/x86_64-linux-gnu/libnss_files-2.13.so
7fd3611b1000-7fd3611bb000 r-xp 00000000 08:01 1466891                    /lib/x86_64-linux-gnu/libnss_nis-2.13.so
7fd3611bb000-7fd3613ba000 ---p 0000a000 08:01 1466891                    /lib/x86_64-linux-gnu/libnss_nis-2.13.so
7fd3613ba000-7fd3613bb000 r--p 00009000 08:01 1466891                    /lib/x86_64-linux-gnu/libnss_nis-2.13.so
7fd3613bb000-7fd3613bc000 rw-p 0000a000 08:01 1466891                    /lib/x86_64-linux-gnu/libnss_nis-2.13.so
7fd3613bc000-7fd3613d1000 r-xp 00000000 08:01 1466681                    /lib/x86_64-linux-gnu/libnsl-2.13.so
7fd3613d1000-7fd3615d0000 ---p 00015000 08:01 1466681                    /lib/x86_64-linux-gnu/libnsl-2.13.so
7fd3615d0000-7fd3615d1000 r--p 00014000 08:01 1466681                    /lib/x86_64-linux-gnu/libnsl-2.13.so
7fd3615d1000-7fd3615d2000 rw-p 00015000 08:01 1466681                    /lib/x86_64-linux-gnu/libnsl-2.13.so
7fd3615d2000-7fd3615d4000 rw-p 00000000 00:00 0
7fd3615d4000-7fd3615db000 r-xp 00000000 08:01 1466617                    /lib/x86_64-linux-gnu/libnss_compat-2.13.so
7fd3615db000-7fd3617da000 ---p 00007000 08:01 1466617                    /lib/x86_64-linux-gnu/libnss_compat-2.13.so
7fd3617da000-7fd3617db000 r--p 00006000 08:01 1466617                    /lib/x86_64-linux-gnu/libnss_compat-2.13.so
7fd3617db000-7fd3617dc000 rw-p 00007000 08:01 1466617                    /lib/x86_64-linux-gnu/libnss_compat-2.13.so
7fd3617dc000-7fd361956000 r-xp 00000000 08:01 1466612                    /lib/x86_64-linux-gnu/libc-2.13.so
7fd361956000-7fd361b56000 ---p 0017a000 08:01 1466612                    /lib/x86_64-linux-gnu/libc-2.13.so
7fd361b56000-7fd361b5a000 r--p 0017a000 08:01 1466612                    /lib/x86_64-linux-gnu/libc-2.13.so
7fd361b5a000-7fd361b5b000 rw-p 0017e000 08:01 1466612                    /lib/x86_64-linux-gnu/libc-2.13.so
7fd361b5b000-7fd361b60000 rw-p 00000000 00:00 0
7fd361b60000-7fd361b7f000 r-xp 00000000 08:01 1466901                    /lib/x86_64-linux-gnu/ld-2.13.so
7fd361d58000-7fd361d5b000 rw-p 00000000 00:00 0
7fd361d7c000-7fd361d7d000 rw-p 00000000 00:00 0
7fd361d7d000-7fd361d7f000 rw-p 00000000 00:00 0
7fd361d7f000-7fd361d80000 r--p 0001f000 08:01 1466901                    /lib/x86_64-linux-gnu/ld-2.13.so
7fd361d80000-7fd361d81000 rw-p 00020000 08:01 1466901                    /lib/x86_64-linux-gnu/ld-2.13.so
7fd361d81000-7fd361d82000 rw-p 00000000 00:00 0
7fff96afb000-7fff96b1c000 rw-p 00000000 00:00 0                          [stack]
7fff96bbc000-7fff96bbd000 r-xp 00000000 00:00 0                          [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]
sudo: pam_mount.c:417: modify_pm_count: Assertion `user != ((void *)0)' failed.
Aborted
$

mca_disable_dma – channel to disable DMA on

1. mca_disable_dma – channel to disable DMA on

void mca_disable_dma(unsigned int dmanr);
dmanr  DMA channel

2. Classroom

First  of  all,  DMA  (per  se) is  almost  entirely  obsolete.  As
originally defined,  DMA controllers  depended on thefact  that the
bus had  separate lines  to assert for  memory read/write,  and I/O
read/write. The DMA controller  took advantage of that by asserting
both  a memory  read and  I/O  write (or  vice versa)  at the  same
time. The DMA controller then generated successive addresses on the
bus, and  data was read from  memory and written to  an output port
(or vice versa) each bus cycle.

The  PCI bus,  however, does  not  have separate  lines for  memory
read/write and  I/O read/write. Instead,  it encodes one  (and only
one) command for  any given transaction. Instead of  using DMA, PCI
normally does  bus-masteringtransfers. This means instead  of a DMA
controller that transfers memory between the I/O device and memory,
the I/O device itself transfers data directly to or from memory.

As for what else  the CPU can do at the time,  it all depends. Back
when  DMA was  common, the  answer was  usually "not  much"  -- for
example,  under early  versions of  Windows, reading  or  writing a
floppy disk (which  did use the DMA controller)  pretty much locked
up the system for the duration.

Nowadays,  however, the memory  typically has  considerably greater
bandwidth than the  I/O bus, so even while  a peripheral is reading
or writing memory, there's usually  a fair amount of bandwidth left
over for the CPU to use.  In addition, a modern CPU typically has a
fair large cache, so it  can often execute some instruction without
using main memory at all.

source : http://stackoverflow.com/questions/5150719/direct-memory-access-dma-how-does-it-work