Google
 

Saturday, March 17, 2007

感悟 3/17/2007

  1. 只有当你拥有了驾驭金钱的能力,它才会老到你的身边。如果你拥有了金钱,但是没有这种能力,这就像开着一辆宝马却没有驾照-这是你就很危险。
  2. 无论做什么行业,阅读和写作能力是最重要和必要的能力。
  3. 中国缺千里马,但更缺伯乐-我要由千里马成长为伯乐!
  4. 恐惧因记忆而生,体会自己的恐惧!
  5. 良好的心态是成就一切的基础和必要条件!

--
Happy day, happy life!

Friday, March 16, 2007

Daily Work Conclusion 3/16/2007

Gain:
  1. Can have a rest when tired.
  2. Write down something gained from work ASAP.
  3. The conclusion is done today.
  4. Good communication with my wife.
  5. Try to do some exercise at home.

Comments:
  1. Relax myself.
  2. Focus on my idea.
  3. Step forward day by day.

--
Happy day, happy life!

Thursday, March 15, 2007

Daily Work Conclusion 3/15/2007

Gain:
  1. I start to read boot part of the kernel code. It is a great step.
  2. List of Available JGsoft Custom Syntax Coloring Schemes
  3. How config customer error setting in web.config: here.
  4. Find out some problems of my work habit.
  5. I did the daily work conclusion.
  6. I have exercised this morning.

Comments:
  1. Not all today's tasks are complete. Because I always change my focus when new idea comes.
  2. Work very tired and less efficient
  3. I missed to read book at noon and spent too much time on computer.
  4. Not set the calendar before starting to work.

Solution:
  1. Have a rest when feeling tired to keep working on high efficiency.
  2. Feel relax to have a rest.
  3. Focus only on one item at any time. When anything new comes just think about it on priority and add it into the daily schedule. Focus on the item scheduled in my Calendar.
  4. When come out any idea, write it down and then go on with my focus.
  5. Everyday, first high priority task is to set my daily schedule. Make it a habit.
Keep on going.
--
Happy day, happy life!

AS86 Manual page

as86

REF:http://www.fifi.org/cgi-bin/man2html/usr/share/man/man1/as86.1.gz
Section: User Commands (1)
Updated: Mar, 1999
Index
Return to Main Contents
 

NAME

as86 - Assembler for 8086..80386 processors  

SYNOPSIS

as86 [-0123agjuw] [-lm[list]] [-n name] [-o obj] [-b[bin]] [-s sym] [-t textseg] src

as86_encap prog.s prog.v [prefix_] [as86 options]

 

DESCRIPTION

as86 is an assembler for the 8086..80386 processors, it's syntax is closer to the intel/microsoft form rather than the more normal generic form of the unix system assembler.

The src file can be '-' to assemble the standard input.

This assembler can be compiled to support the 6809 cpu and may even work.

as86_encap is a shell script to call as86 and convert the created binary into a C file prog.v to be included in or linked with programs like boot block installers. The prefix_ argument is a prefix to be added to all variables defined by the source, it defaults to the name of the source file. The variables defined include prefix_start prefix_size and prefix_data to define and contain the code, plus integers containing the values of all exported labels. Either or both the prog.s and prog.v arguments can be '-' for standard in/out.

 

OPTIONS

-0
start with 16-bit code segment, warn for all instructions > 8086
-1
start with 16-bit code segment, warn for all instructions > 80186
-2
start with 16-bit code segment, warn for all instructions > 80286
-3
start with 32-bit code segment, don't warn for any instructions. (not even 486 or 586)
-a
enable partial compatibility with Minix asld. This swaps the interpretation of round brackets and square brackets as well as making alterations to the code generation and syntax for 16bit jumps and calls. ("jmp @(bx)" is then a valid instruction)
-g
only put global symbols in object or symbol file
-j
replace all short jumps with similar 16 or 32 bit jumps, the 16 bit conditional branches are encoded as a short conditional and a long unconditional branch.
-O
this causes the assembler to add extra passes to try to use forward references to reduce the bytes needed for some instructions. If the labels move on the last pass the assembler will keep adding passes until the labels all stabilise (to a maximum of 30 passes) It's probably not a good idea to use this with hand written assembler use the explicit br bmi bcc style opcodes for 8086 code or the jmp near style for conditional i386 instructions and make sure all variables are defined before they are used.
-l
produce list file, filename may follow
-m
print macro expansions in listing
-n
name of module follows (goes in object instead of source name)
-o
produce object file, filename follows
-b
produce a raw binary file, filename may follow. This is a 'raw' binary file with no header, if there's no -s option the file starts at location 0.
-s
produce an ASCII symbol file, filename follows. The format of this table is designed to be easy to parse for encapsulation and related activities in relation to binary files created with the -b option. If a binary file doesn't start at location zero the first two items in the table are the start and end addresses of the binary file.
-u
assume undefined symbols are imported-with-unspecified segment.
-w-
allow the assembler to print warning messages.
-t n
move all text segment data in segment n+3.
 

AS86 SOURCE

Special characters
*
Address of the start of the current line.
; !
Either of these marks the start of a comment. In addition any 'unexpected' character at the start of a line is assumed to be a comment (but it's also displayed to the terminal).
$
Prefix for hexadecimal numbers, the 'C' syntax, eg 0x1234, is also accepted.
%
Prefix for binary numbers.
#
Prefix for immediate operands.
[ ]
Specifies an indirect operand.
Unlike MASM the assembler has no type information on labels just a segment and offset. This means that the way this operator and the immediate prefix work are like traditional assemblers.

Examples:
       mov ax,bx

       jmp bx

Direct register addressing, the jump copies BX into PC.

        mov ax,[bx]
jmp [bx]
Simple indirect register addressing, the jump moves the contents of the location specified by BX into the PC.

       mov ax,#1234

Immediate value, ax becomes 1234.

        mov ax,1234
mov ax,_hello
mov ax,[_hello]
Absolute addressing, ax is set to contents of location 1234. Note the third option is not strictly consistant but is in place mainly for asld compatibility.

        mov ax,_table[bx]
mov ax,_table[bx+si]
mov eax,_table[ebx*4]

mov ax,[bx+_table]
mov ax,[bx+si+_table]
mov eax,[ebx*4+_table]
Indexed addressing, both formats are ok, I think the first is more correct but I tend to used the second. :-)
Conditionals
IF, ELSE, ELSEIF, ENDIF
Numeric condition
IFC, ELSEIFC
String compare (str1,str2)
FAIL .FAIL
Generate user error. Segment related
.TEXT .ROM .DATA .BSS
Set current segment. These can be preceded by the keyword .SECT
LOC
Set numeric segment 0=TEXT, 3=DATA,ROM,BSS, 14=MAX. The segment order set by the linker is now 0,4,5,6,7,8,9,A,B,C,D,E,1,2,3. Segment 0 and all segments above 3 are assumed to be text segment. Note the 64k size restrictions are not imposed for segments 3-14. Label type definition
EXPORT PUBLIC .DEFINE
Export label defined in this object
ENTRY
Force linker to include the specified label in a.out
.GLOBL .GLOBAL
Define label as external and force import even if it isn't used.
EXTRN EXTERN IMPORT .EXTERN
Import list of externally defined labels
NB: It doesn't make sense to use imports for raw binary files.
.ENTER
Mark entry for old binary file (obs) Data definition
DB .DATA1 .BYTE FCB
List of 1 byte objects.
DW .DATA2 .SHORT FDB .WORD
List of 2 byte objects.
DD .DATA4 .LONG
List of 4 byte objects.
.ASCII FCC
Ascii string copied to output.
.ASCIZ
Ascii string copied to output with trailing nul byte. Space definition
.BLKB RMB .SPACE
Space is counted in bytes.
.BLKW .ZEROW
Space is counted in words. (2 bytes each)
COMM .COMM LCOMM .LCOMM
Common area data definition Other useful pseudo operations.
.ALIGN .EVEN
Alignment
EQU
Define label
SET
Define re-definable label
ORG .ORG
Set assemble location
BLOCK
Set assemble location and stack old one
ENDB
Return to stacked assemble location
GET INCLUDE
Insert new file (no quotes on name)
USE16 [cpu]
Define default operand size as 16 bit, argument is cpu type the code is expected to run on (86, 186, 286, 386, 486, 586) instructions for cpus later than specified give a warning.
USE32 [cpu]
Define default operand size as 32 bit, argument is cpu type the code is expected to run on (86, 186, 286, 386, 486, 586) instructions for cpus later than specified give a warning. If the cpu is not mentioned the assembler ensures it is >= 80386.
END
End of compilation for this file.
.WARN
Switch warnings
.LIST
Listings on/off (1,-1)
.MACLIST
Macro listings on/off (1,-1) Macros, now working, the general form is like this.


    MACRO sax
       mov ax,#?1
    MEND
    sax(1)

Unimplemented/unused.

IDENT
Define object identity string.
SETDP
Set DP value on 6809
MAP
Set binary symbol table map number.
Registers

BP BX DI SI
EAX EBP EBX ECX EDI EDX ESI ESP
AX CX DX SP
AH AL BH BL CH CL DH DL
CS DS ES FS GS SS
CR0 CR2 CR3 DR0 DR1 DR2 DR3 DR6 DR7
TR3 TR4 TR5 TR6 TR7 ST
Operand type specifiers
BYTE DWORD FWORD FAR PTR PWORD QWORD TBYTE WORD NEAR

The 'near and 'far' do not allow multi-segment programming, all 'far' operations are specified explicitly through the use of the instructions: jmpi, jmpf, callf, retf, etc. The 'Near' operator can be used to force the use of 80386 16bit conditional branches. The 'Dword' and 'word' operators can control the size of operands on far jumps and calls.

General instructions.
These are in general the same as the instructions found in any 8086 assembler, the main exceptions being a few 'Bcc' (BCC, BNE, BGE, etc) instructions which are shorthands for a short branch plus a long jump and 'BR' which is the longest unconditional jump (16 or 32 bit).
Long branches
BCC BCS BEQ BGE BGT BHI BHIS BLE BLO BLOS BLT BMI BNE BPC BPL BPS BVC BVS BR
Intersegment
CALLI CALLF JMPI JMPF
Segment modifier instructions
ESEG FSEG GSEG SSEG
Byte operation instructions
ADCB ADDB ANDB CMPB DECB DIVB IDIVB IMULB INB INCB MOVB MULB NEGB NOTB ORB OUTB RCLB RCRB ROLB RORB SALB SARB SHLB SHRB SBBB SUBB TESTB XCHGB XORB
Standard instructions
AAA AAD AAM AAS ADC ADD AND ARPL BOUND BSF BSR BSWAP BT BTC BTR BTS CALL CBW CDQ CLC CLD CLI CLTS CMC CMP CMPS CMPSB CMPSD CMPSW CMPW CMPXCHG CSEG CWD CWDE DAA DAS DEC DIV DSEG ENTER HLT IDIV IMUL IN INC INS INSB INSD INSW INT INTO INVD INVLPG INW IRET IRETD J JA JAE JB JBE JC JCXE JCXZ JE JECXE JECXZ JG JGE JL JLE JMP JNA JNAE JNB JNBE JNC JNE JNG JNGE JNL JNLE JNO JNP JNS JNZ JO JP JPE JPO JS JZ LAHF LAR LDS LEA LEAVE LES LFS LGDT LGS LIDT LLDT LMSW LOCK LODB LODS LODSB LODSD LODSW LODW LOOP LOOPE LOOPNE LOOPNZ LOOPZ LSL LSS LTR MOV MOVS MOVSB MOVSD MOVSW MOVSX MOVW MOVZX MUL NEG NOP NOT OR OUT OUTS OUTSB OUTSD OUTSW OUTW POP POPA POPAD POPF POPFD PUSH PUSHA PUSHAD PUSHF PUSHFD RCL RCR REP REPE REPNE REPNZ REPZ RET RETF RETI ROL ROR SAHF SAL SAR SBB SCAB SCAS SCASB SCASD SCASW SCAW SEG SETA SETAE SETB SETBE SETC SETE SETG SETGE SETL SETLE SETNA SETNAE SETNB SETNBE SETNC SETNE SETNG SETNGE SETNL SETNLE SETNO SETNP SETNS SETNZ SETO SETP SETPE SETPO SETS SETZ SGDT SHL SHLD SHR SHRD SIDT SLDT SMSW STC STD STI STOB STOS STOSB STOSD STOSW STOW STR SUB TEST VERR VERW WAIT WBINVD XADD XCHG XLAT XLATB XOR
Floating point
F2XM1 FABS FADD FADDP FBLD FBSTP FCHS FCLEX FCOM FCOMP FCOMPP FCOS FDECSTP FDISI FDIV FDIVP FDIVR FDIVRP FENI FFREE FIADD FICOM FICOMP FIDIV FIDIVR FILD FIMUL FINCSTP FINIT FIST FISTP FISUB FISUBR FLD FLD1 FLDL2E FLDL2T FLDCW FLDENV FLDLG2 FLDLN2 FLDPI FLDZ FMUL FMULP FNCLEX FNDISI FNENI FNINIT FNOP FNSAVE FNSTCW FNSTENV FNSTSW FPATAN FPREM FPREM1 FPTAN FRNDINT FRSTOR FSAVE FSCALE FSETPM FSIN FSINCOS FSQRT FST FSTCW FSTENV FSTP FSTSW FSUB FSUBP FSUBR FSUBRP FTST FUCOM FUCOMP FUCOMPP FWAIT FXAM FXCH FXTRACT FYL2X FYL2XP1
 

Using GASP

The Gnu assembler preprocessor provides some reasonable implementations of user biased pseudo opcodes.

It can be invoked in a form similar to:

gasp
[-a...] file.s [file2.s] |
as86 [...] - [-o obj] [-b bin] Be aware though that Gasp generates an error for .org commands, if you're not using alternate syntax you can use org instead, otherwise use block and endb. The directive export is translated into .global, which forces an import, if you are making a file using -b use public or .define instead.

The GASP list options have no support in as86.

 

SEE ALSO

as(1), ld86(1), bcc(1)  

BUGS

The 6809 version does not support -0, -3, -a or -j.

If this assembler is compiled with BCC this is classed as a 'small' compiler, so there is a maximum input line length of 256 characters and the instruction to cpu checking is not included.

The checking for instructions that work on specific cpus is probably not complete, the distinction between 80186 and 80286 is especially problematic.

The .text and .data pseudo operators are not useful for raw binary files.

When using the org directive the assembler can generate object files that may break ld86(1).


 

Index

NAME

SYNOPSIS

DESCRIPTION

OPTIONS

AS86 SOURCE

Using GASP

SEE ALSO

BUGS


This document was created by man2html, using the manual pages.
Time: 08:35:46 GMT, March 15, 2007

--
Happy day, happy life!

Wednesday, March 14, 2007

New day, New Life!

新的一天新的开始!享受生活,享受今天!

  1. 从今天开始,我要每天花15做工作总结(这是老婆给我的建议!)。
  2. 每天读一份报纸


--
Happy day, happy life!

Tools to generate documentation of source code

  1. Doxygen
    • Doxygen is a documentation system for C++, C, Java, Objective-C, Python, IDL (Corba and Microsoft flavors) and to some extent PHP, C#, and D.

      It can help you in three ways:

      Doxygen is developed under Linux and Mac OS X, but is set-up to be highly portable. As a result, it runs on most other Unix flavors as well. Furthermore, executables for Windows are available.

  2. Microsoft HTML Help
    • Microsoft® HTML Help is the standard help system for the Windows platform. Authors can use HTML Help to create online help for a software application or to create content for a multimedia title or Web site. Developers can use the HTML Help API to program a host application or hook up context-sensitive help to an application. As an information delivery system, HTML Help is suited for a wide range of applications, including training guides, interactive books, and electronic newsletters, as well as help for software applications.

      HTML Help offers some distinct advantages over standard HTML, such as the ability to implement a combined table of contents and index and the use of keywords for advanced hyperlinking capability. The HTML Help compiler (part of the HTML Help Workshop) makes it possible to compress HTML, graphic, and other files into a relatively small compiled help (.chm) file, which can then be distributed with a software application, or downloaded from the Web.

      HTML Help consists of an online Help Viewer, related help components, and help authoring tools from Microsoft Corporation. The Help Viewer uses the underlying components of Microsoft Internet Explorer to display help content. It supports HTML, ActiveX®, Java™, scripting languages (JScript®, and Microsoft Visual Basic® Scripting Edition), and HTML image formats (.jpeg, .gif, and .png files). The help authoring tool, HTML Help Workshop, provides an easy-to-use system for creating and managing help projects and their related files.

    • Microsoft HTML Help Workshop- Tutorial
  3. LaTeX
    • \mathrm{L\!\!^{{}_{\scriptstyle A}} \!\!\!\!\!\;\; T\!_{\displaystyle E} \! X}, written as LaTeX in plain text, is a document markup language and document preparation system for the TeX typesetting program.

      It is widely used by mathematicians, scientists, philosophers, engineers, and scholars in academia and the commercial world, and by others as a primary or intermediate format ( e.g. translating DocBook and other XML-based formats to PDF) because of the quality of typesetting achievable by TeX. It offers programmable desktop publishing features and extensive facilities for automating most aspects of typesetting and desktop publishing, including numbering and cross-referencing, tables and figures, page layout and bibliographies.

      LaTeX is intended to provide a high-level language to access the power of TeX. LaTeX essentially comprises a collection of TeX macros, and a program to process LaTeX documents. Since TeX's formatting commands are very low-level, it is usually much simpler for end-users to use LaTeX.

      LaTeX was originally written in 1984 by Leslie Lamport at SRI International and has become the dominant method for using TeX—few people write in plain TeX anymore. The current version is \mathrm{L\!\!^{{}_{\scriptstyle A}} \!\!\!\!\!\;\; T\!_{\displaystyle E} \! X} \, 2_{\displaystyle \varepsilon} (LaTeX2e). LaTeX, like TeX, is free software.

  4. Graphviz - Graph Visualization Software
    • Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. Automatic graph drawing has many important applications in software engineering, database and web design, networking, and in visual interfaces for many other domains.

      Graphviz is open source graph visualization software. It has several main graph layout programs. See the gallery for some sample layouts. It also has web and interactive graphical interfaces, and auxiliary tools, libraries, and language bindings.

      The Mac OS X edition of Graphviz, by Glen Low, won two 2004 Apple Design Awards.

      The Graphviz layout programs take descriptions of graphs in a simple text language, and make diagrams in several useful formats such as images and SVG for web pages, Postscript for inclusion in PDF or other documents; or display in an interactive graph browser. (Graphviz also supports GXL, an XML dialect.)

      Graphviz has many useful features for concrete diagrams, such as options for colors, fonts, tabular node layouts, line styles, hyperlinks, and custom shapes.

      In practice, graphs are usually generated from an external data sources, but they can also be created and edited manually, either as raw text files or within a graphical editor. (Graphviz was not intended to be a Visio replacement, so it is probably frustrating to try to use it that way.)




Happy day, happy life!

Tuesday, March 13, 2007

<> reading note Chapter 2

2.3 Interrupt Mechanism
  1. Two 8259A
  2. The address: main 8259A (0x20), the slave (0xA0)
  3. The IN and OUT instructions are used to control the 8259A initialization by CPU
  4. The INT instruction is used to inform CPU by 8259A that there is an interruption occurred
  5. Interrupt types:hardware interrupt and software interrupt
  6. int0~int3(0x00~0x1f) used by Intel as exceptions
  7. int32~int47(0x20~0x2f) used by Linux corresponding to the IRQ0~IRQ15 of 8259A
  8. The Linux sets the system_call sent by user programs as interrupt int128(0x80)

2.4 System Timer
  1. The programmable time chip is Intel82593 and It sends a signal (IRQ0) at a constant interval time.
  2. Every time the timer_interrupt is called to accumulate the count of the intervals since the system starts. The count is stored in the variable: jiffies
  3. Every time the  do_timer will be called to accumulate the time of the current running process by its DPL
  4. The kernel process will not be cut over by the scheduler, but the user process will.

2.5 Linux  Process Control
  • The system call fork is used to create processes.
  • For Linux 0.11 there are at most 64 processes existing at the same time
  • There kernel stack is divided from the user stack

  1. Task Data Structure
    • The kernel uses the process table to manage the processes
    • The task_struct (PCB:Process Control Block, PD:Processor Descriptor)defines the data structure of a process and every process that currently exists has a item in the process table.
    • The process context is including all registers' value, the state of the process, the data in the stack.
    • In Linux, the process context is stored in the task_struct.

    • The task_struct of linux kernel 0.11 in include/linux/sched.h
      struct task_struct {
      /* these are hardcoded - don't touch */
          
      long state;    /* -1 unrunnable, 0 runnable, >0 stopped  */
          
      long counter;
          
      long priority;
          
      long signal;
          
      struct sigaction sigaction[32];
          
      long blocked;    /* bitmap of masked signals  */
      /* various fields */
          
      int exit_code;
          unsigned 
      long start_code,end_code,end_data,brk,start_stack;
          
      long pid,father,pgrp,session,leader;
          unsigned 
      short uid,euid,suid;
          unsigned 
      short gid,egid,sgid;
          
      long alarm;
          
      long utime,stime,cutime,cstime,start_time;
          unsigned 
      short used_math;
      /* file system info */
          
      int tty;        /* -1 if no tty, so it must be signed  */
          unsigned 
      short umask;
          
      struct m_inode * pwd;
          
      struct m_inode * root;
          
      struct m_inode * executable;
          unsigned 
      long close_on_exec;
          
      struct file * filp[NR_OPEN];
      /* ldt for this task 0 - zero 1 - cs 2 - ds&ss */
          
      struct desc_struct ldt[3];
      /* tss for this task */
          
      struct tss_struct tss;
      };

  2. Task Running State
    • TASK_RUNNING             : The process is running or ready to run
    • TASK_INTERRUPTIBLE     : The process is sleeping and waiting an interrupt, resources or a signal.
    • TASK_UNINTERRUPTIBLE : The process is sleeping but can be waked up only by the wake_up().
    • TASK_STOPPED             : The process is stopped by having received a signal(SIGSTOP,SIGTSTP,SIGTTIN,or SIGTTOU) and it is to run when the signal (SIGCONT) is received.
    • TASK_ZOMBIE              : The process is at this state when it is stopped but before its parent process inquired about its state.
    • To prevent kernel data error during switching between processes, all interrupts are disabled when the kernel runs the code in the critical area.
  3. Process Initialization
    1. The process to initialize the kernel
      1. Booting ...
      2. The loader loads the kernel into memory
      3. Jump into and running in the protected mode
      4. Execute the init/main.c to initialize the system. The main.c will first decide how to allocate the system physical memory and then call the initialization functions to initialize Memory Management, Interrupt Handling, Block and Character Device, Process Management and Hard Disk and Soft Disk hardwares and so on.
      5. Then the program moves itself to TASK 0 and call fork() to create Process 1
      6. The Process 1 will go on to initialize the application environment can call the log application of Shell.
      7. Now the system is running.
    2. The Process 0 will be called at the system idle time. It only calls the pause() and the schedule function.
    3. The action to move and run into TASK 0 is completed by move_to_user_mode macro (include/asm/system.h).
    4. The steps to initialize the TASK 0
      1. Set the data structure's value of TASK 0 (include/linux/sched.h)
      2. Add descriptors of TASK 0's TSS and LDT and load them into tr (Task Register) and ldtr (Local Descriptor Register).
    5. The Kernel initialization code is the code of the TASK 0 initialization code. The difference is that to initialize the kernel has the DPL 0 but the TASK 0 initialization has DPL 3.
    6. The move_to_user_mode macro uses the method that using interrupt return instruction results the DPL changes.
  4.  Creating New Process
    1. In Linux, use fork() to create new process.
    2. All processes are copies of Process 0 and all are child of Process 0
    3. Steps to create new process:
      1. The system first finds an empty item in the TASK array. If there is no empty item ( the max item count is 64), the fork() will return with error.
      2. Then system requires a memory page to store the data structure of the new TASK and copies all the task data structure and its data contents of the current process as the task data structure template for the new process. To prevent the new process which is not completely created from being executed by the schedule function, the state of the new process is set as TASK_UNINTERRUPIBLE.
      3. Then update the contents of the copied data structure.
        1. Set the current process as the parent of the new process
        2. Clear the signal bmp, reset each system statistic value and set 15 system interval as time clip
        3. tss.eax = 0; tss.esp0; tss.ss0; tss.ldt; tss.i387
    4. Process Scheduling (30/652)
      • The Linux processes are robbing mode.
      • The processes robbed are still at TASK_RUNNING state, which are only run by CPU.
      • The process robbing is occurred at the use mode and running in the kernel mode can not be robbed
      • The process schedule in Linux 0.11 is based on the priority queue algorithm.a
      1. Schedule processes
        1. Scanning the TASK array, schudle() decides which process' running time is the  fewest by the counter value.  The bigger the counter value is the fewer time the process is running. The process with the biggest counter will be selected by the scheduler to be switched to.
        2. If the time chips of all processes at TASK_RUNNING are run out, system will recompute the time chip of every process including processes at TASK_SLEEP by its priority. counter=(counter/2) + priority.
        3. Then the schedule() function scans all the processes at TASK_RUNNING and repeat the steps above until a process is selected.
        4. At last switch_to() executes the actual process switching operation.
        5. If there is no process to select, the system will run the Process 0.Save & close
      2. Switch processes
        1. The switch_to() executes the actual operation of process switching.

    5. Stop processes
      1. Pending...
   
2.6 The Memory Using in Linux Kernel
  1. Blocks of memory Divided by Linux
    1. Kernel mode block is at the start of memory
    2. Cache Memory:
    3. Virtual Disk
    4. Main Memory block
  2. Memory Management System In Intel CPU
    1. Segmentation System
    2. Paging System (can be selected by system programmer)
  3. Different Addresses
    1. Logical Address of Programs : the offset address
    2. Linear Address of CPU : it is between the Logical address and the physical address in the address conversion. The capacity of the Intel 80386 linear address is 4G.
    3. Physical Address :
  4. Virtual Memory means the computer can use much more memory that it actually has. In Linux 0.11, every program is assigned 64M memory in size.
  5. Virtual Memory Management
    1. When a program accesses a memory address that not exists in the memory pages will cause page error interrupt and the linear address which caused the interrupt will be placed in CR2 (Control register)
    2. The interrupt handler gets the specific address that caused the page exception and loads the requested page from secondary memory space to memory.
    3. If all physical memory has been occupied, use part of the secondary memory space as swapper, switch the memory pages that are not used currently to this swapper and then load the requested page into memory. This is the missing page loading mechanism and it is implemented in the mm/memory.c.
    4. Addressing Using Segment Concept
      1. Intel CPU uses the Segment concept to implement addressing
      2. Every segment defines some specific memory block and access priority and so on. Every program can have several segments.
      3. In Linux 0.11, the address mapping from program logical address to linear address uses the global descriptor table (GDT) and local descriptor table (LDT) of CPU. The global address memory is mapped by GDT and the LDT maps the local address memory. The two constitutes virtual address memory.
      4. In Linux 0.11, there is no system segment descriptor table.
    5. Memory Paging Management
      1. This theory divides the main memory into pages one of which is 4096kb in size. The page is used as the unit when programs request memory.
      2. Using this method, every running process can use much larger continuous address memory that it really has.
        1. In Intel 80386, CPU can supply 4G linear address memory in size.
        2. In Linux 0.11, the GDT has at most 256 items among which two are idlesse, two are used by system and every process uses two items. Therefor, system can have at most 127 tasks. Every task can be assigned to 64MB virtual address memory. Totally, it is 8GB. In Linux 0.11, the maximum number of tasks defined manually is 64. So it requires 4GB virtual address memory totally same as the size CPU can supply.

      3. The virtual address of processes is first mapped as the linear address by GDT and LDT, then the linear address is mapped as physical address by Page Directory Table (PDT) and Page Table (PT).
      4. In order to use physical memory, the linear address of processes is dynamically mapped to main memory pages by PT. The logical address plus (TASK Number * 64MB) is the linear address.
      5. After Linux 0.99, every process can use all 4GB address memory independently.

2.7 Stack Using In Linux (Pending 35 of 652)

2.8 Directory Tree of Linux Kernel Source Code

// The Directory Tree of Linux Kernel 0.11
\---linux- 0.11  
+---boot       // Assembly programs to boot system
+---fs         // File System
+---include    // Head Files (*.h)
| +---asm       // Related to CPU architecture
| +---linux     // Exclusive used by Kernel
| \---sys       // Data structures of System
+---init       // Programs to initialize Kernel
+---kernel     // Process Scheduler, Signal Handler, System Call of Kernel
| +---blk_drv   // Block Device Driver
| +---chr_drv   // Character Device Driver
| \---math      // Math Co-processor Simulator
+---lib        // Kernel Function Library
+---mm         // Memory Management Programs
\---tools      //  Tools to generate Kernel Image file



//Kernel File Tree:
//
\---linux- 0.11
| Makefile
|
+---boot         // It's function is to guide the kernel to boot,
                    // load the kernel code into memory
                    // and do some preparations for running into the 32-bit protection mode.
| bootsect.s   // disk bootstrap program
| head.s        // will be compiled to the head of the system module
                   // and used to set hardware probing and
                   // initialize the memory page management

| setup.s      // used to read hardware configuration parameters and move kernel system module to proper location
|
+---fs         // to manage the using of cache blocks in Cache Storage and file systems of block devices
| bitmap.c        // to handle the bitmaps of the i-th node and logical data blocks in file system
| block_dev.c   // functions to read and write to data blocks
| buffer.c    // to manage the using of cache blocks
| char_dev.c      // has the function to read and write to character devices
| exec.c     // to supply a function : do_execve() to run programs
| fcntl.c     // to supply functions of IO Control of file system
| file_dev.c   // functions to read and write to files based on i-th note and file descriptor
| file_table.c // only defined a data structure of file descriptor
| inode.c      // functions to control the i-th node in file system
| ioctl.c       // to supply functions to control IO of character block devices by referring to functions in kernel/chr_drv/tty.c.
| Makefile
| namei.c    // to manage the name of file and directory.
| open.c      // contains functions to modify file properties, create and close files
| pipe.c       // functions to read and write to pipelines, and create pipelines.
| read_write.c    // to define three file functions: read, write and locate
| stat.c            // two functions to gain file status
| super.c         // contains functions to handle the supper blocks of file system
| truncate.c      // to release device and data resources  used by files  which will be deleted during deleting these files
|
+---include
| | a. out.h      // defines the executable file format of a.out
| |  const.h
| | ctype.h     // defines same macro of type determination and conversion of characters
| | errno.h     // system error numbers
| | fcntl.h      // file control
| | signal.h    //
| | stdarg.h
| | stddef.h
| |  string.h
| | termios.h
| | time.h
| | unistd.h
| | utime.h
| |
| +---asm
| | io.h
| | memory.h
| | segment.h
| | system.h
| |
| +---linux
| | config.h
| | fdreg.h
| | fs.h
| | hdreg.h
| | head.h
| | kernel.h
| | mm.h
| | sched.h
| | sys.h
| | tty.h
| |
| \---sys
| stat.h
| times.h
| types.h
| utsname.h
| wait.h
|
+---init
| main.c
|
+---kernel
| | asm.s
| | exit.c
| | fork.c
| | Makefile
| | mktime.c
| | panic.c
| | printk.c
| | sched.c
| | signal.c
| | sys.c
| | system_call.s
| | traps.c
| | vsprintf.c
| |
| +---blk_drv
| | blk.h
| | floppy.c
| | hd.c
| | ll_rw_blk.c
| | Makefile
| | ramdisk.c
| |
| +---chr_drv
| | console.c
| | keyboard.S
| | Makefile
| | rs_io.s
| | serial.c
| | tty_io.c
| | tty_ioctl.c
| |
| \---math
| Makefile
| math_emulate.c
|
+---lib
| close.c
| ctype.c
| dup.c
| errno.c
| execve.c
| Makefile
| malloc.c
| open.c
| setsid.c
| string.c
| wait.c
| write.c
| _exit.c
|
+---mm
| Makefile
| memory.c
| page.s
|
\
---tools
build.c

  1. boot (39 of 652)
  2. fs
    1. Regarding to the reading and writing action of block device data, the file system will use Cache Storage Block and block device drivers and the file system function set itself will not deal with block device drivers directly.
  3. include
  4. init
  5. kernel
  6. lib
  7. mm
  8. tools

2.9 Relationship Between Kernel System and User Programs
  1. Two parts of system interface to user
    1. Interrupt call : int 0x80
    2. Kernel Lib

2.10 linux/makefile

Pending


--
Happy day, happy life!

Monday, March 12, 2007

培养好的工作和生活习惯

  1. 生活
    1. 早睡,早起
    2. 早晨锻炼身体
    3. 把工作和技术学习控制在8小时内,8小时外是享受生活和学习技术以外的知识的时间
    4. 周末安排休息和调节生活:
  2. 工作
    1. 将工作限时计划,该做什么就只做什么
    2. 45分钟为间隔,加休息时间10-15分钟
    3. 中午11:30-13:00休息时间:吃饭和看技术以外的书籍或者休息
  3. Schedule
    1. Getup:
    2. Sleep:

Linux Kernel download free books

1. Linux Kernel in a Nutshell

2. Embedded Linux Primer: A Practical Real-World Approach

3. LPI Linux Certification in a Nutshell

4. User Mode Linux(R)

5. Linux for Embedded and Real-Time Applications

6. Rootkits: Subverting the Windows Kernel

7. Solaris Internals: Solaris 10 and OpenSolaris Kernel Architecture (2nd Edition)

8. Red Hat Linux Security and Optimization

9. Linux in a Windows World

10. Hacker Linux Uncovered

11. Embedded Linux System Design and Development

12. Embedded Linux System Design and Development

Linux for Embedded and Real-Time Applications

Programming Embedded Systems: With C and Gnu Development Tools

Analog Interfacing to Embedded Microprocessor Systems, Second Edition (Embedded Technology Series)

Real-Time Concepts for Embedded Systems

Embedded Linux: Hardware, Software, and Interfacing

TCP/IP Application Layer Protocols for Embedded Systems (With CD-ROM) (Networking Series)

Embedded System Design

Real Time UML Advances in The UML for Real Time Systems 3rd Edition

Open-Source Robotics and Process Control Cookbook: Designing and Building Robust, Dependable Real-Time Systems

Linux Kernel Internals, Second Edition - Addison Wesley

Linux Network Architecture

The Linux Process Manager

Books about PC and programming

Understanding the Linux Kernel

LPI Linux Certification in a Nutshell

Linux Application Development

Linux Application Development (2nd Edition)

13. Mac OS X Internals: A Systems Approach

14. Understanding Linux Network Internals

15. Real-Time Concepts for Embedded Systems

16. Embedded Linux Primer: A Practical Real-World Approach

17. Programming Embedded Systems: With C and Gnu Development Tools

18. Embedded System Design

19. Analog Interfacing to Embedded Microprocessor Systems, Second Edition Embedded Technology Series)

20. Embedded Linux: Hardware, Software, and Interfacing

21. Open-Source Robotics and Process Control Cookbook: Designing and Building Robust, Dependable Real-Time Systems

22. Real Time UML Advances in The UML for Real Time Systems 3rd Edition

23. Embedded Ethernet and Internet Complete

24. Ambient Intelligence Impact on Embedded System Design

25. Embedded Linux: Hardware, Software, and Interfacing

26. C Programming for Embedded Systems

27. Embedded Systems Design: An Introduction to Processes, Tools and Techniques

28. UNIX Internals: A Practical Approach

29. Solaris Performance and Tools: DTrace and MDB Techniques for Solaris 10 and OpenSolaris

30. UNIX Internals: The New Frontiers

31. Solaris Internals: Solaris 10 and OpenSolaris Kernel Architecture (2nd Edition)

32. Windows NT File System Internals, A Developer’s Guide

33. Operating Systems: Internals and Design Principles (4th Edition)

34. Understanding Linux Network Internals

35. Introduction to Dynamic Systems Theory, Models, and Applications

36. Extending and Embedding PHP

37. The Guru’s Guide to SQL Server Architecture and Internals

38. Real-Time Concepts for Embedded Systems

39. Embedded System Design

40. Embedded Systems Design: An Introduction to Processes, Tools and Techniques

41. C Programming for Embedded Systems

42. Programming Microcontrollers in C (Embedded Technology Series)

43. Embedded Ethernet and Internet Complete

44. TCP/IP Application Layer Protocols for Embedded Systems (With CD-ROM) (Networking Series)

45. Embedded Systems Firmware Demystified (With CD-ROM)

46. Testing Embedded Software