系統程式 -- RSS

MINIX 作業系統的程式碼導覽

by ccckmitccckmit 26 Aug 2010 03:28

boot/        : 啟動相關的程式碼 (addaout.c, boot.c/h, bootlock.s, boothead.s, bootimage.c, 
            doshead.s, image.h, installboot.c, jumpboot.s, masterboot.s, mkfhead.s, 
            mkfile.c, rawfs.c/h
kernel/        : 行程相關的程式碼 (clock.c, config.c/h, debug.c/h, exception.c, glo.h, i8259.c, 
            ipc.h, kernel.h, klib88.s, klib386.s, klib.s, main.c, mpx88.s, mpx386.s, 
            mpx.s, priv.h, proc.c/h, protect.c/h, proto.h, sconst.h, start.c, system.c, 
            table.c, type.h, utility.c,
  system/    : do_xx 的程式, (do_abort.c, do_copy.c, dodevio.c, do_endksig.c, do_exec.c, 
            do_exit.c, do_fork.c, do_getinfo.c, do_getksig.c, do_int86.c, do_iopenable.c, 
            do_irqctl.c, dodo_exec.c, do_fork.c, do_kill.c, do_memset.c, do_newmap.c, 
            do_nice.c, do_privctl.c, do_sdevio.c, do_segctl.c, do_setalarm.c, 
            do_sigreturn.c, do_sigend.c, do_times.c, do_trace.c, do_umap.c, 
            do_unused.c, do_vcopy.c, do_vdevio.c)
servers/    : 訊息傳遞相關的程式碼 (No file)
  ds/        : Data Store Server, (main.c, store.c/h, glo.h, inc.h, proto.h)
  fs/        : File System, (buf.h, cache.c, cache2.c, cdprobe.c, device.c, dmap.c, file.h, 
            filedes.c, fproc.h, fs.h, glo.h, inode.c/h, link.c, lock.c/h, main.c, 
            misc.c, mount.c, open.c, param.h, path.c, pipe.c, protect.c, proto.h, 
            read.c, select.c/h, stadir.c, super.c/h, table.c, time.c, timers.c, 
            type.h, utility.c, write.c)
  inet/        : Networking, (buf.c, clock.c, inet.c, inet_config.c, mnx_eth.c, mq.c, qp.c, 
            sha2.c, sr.c, stacktrace.c, version.c)
    generic/: 網路通用程式, *arp.c/h, assert.h, buf.h, clock.h, eth.c/h, eth_int.h, event.c/h, 
            icmp.c/h, icmp_lib.h, io.c/h, ip.c/h, ip_eth.c/h, ip_int.h, ip_ioctl.c/h, 
            ip_lib.c, ip_ps.c, ip_read.c, ip_write.c, ipr.c/h, psip.c/h, rand256.c/h, 
            sr.h, tcp.c/h, tcp_int.h, tcp_lib.c, tcp_recv.c, tcp_send.c, type.h, udp.c, 
            udp.h, udp_int.h)
    minix3/    : 只有 queryparam.c, .h
  init/        : 只有 init.c , 是所有 Process 的 Father Process.
  is/        : information server, 除錯資訊的 dump.(dump.c, dmp_ds.c, dmp_fs.c, dmp_kernel.c, 
            dmp_pm.c, dmp_rs.c, glo.h, inc.h, is.h, main.c, proto.h)
  pm/        : Process Management, 包含 (alloc.c, break.c, const.h, exec.c, forkexit.c, getset.c, 
            glo.h, main.c, misc.c, mproc.h, param.h, pm.h, proto.h, signal.c, table.c, 
            time.c, timers.c,trace.c, type.h, utility.c
  rs/        : Reincarnation(輪迴轉世) Server, (inc.h, main.c, manager.c/h, proto.h, service.c)
  sm/        : System Process Manager, (沒有 *.c 只有一個 makefile)
drivers/    : IO 驅動程式 (drivers.h)
  at_wini/    : driver for the IBM-AT winchester controller.
  bios_wini/: hard disk driver that uses the ROM BIOS.
  cmos/        : access the CMOS chip to get or set the system time.
  dp8390/    : Ethernet device driver for NS dp8390 based ethernet cards. (dp8390.c, ne2000.c, rtl9029.c, wdeth.c)
  dpeth/    : Ethernet device driver for 3Com Etherlink (3c501) boards, 包含 3c501.c, 3c503.c, 
            3c509.c, 8390.c, devio.c, dp.c, ne.c, netbuff.c, wd.c, 
  floppy/    : Floppy Disk Driver, 包含 floppy.c
  fxp/        : Ethernet device driver for Intel 82557, 82558, 82559, 82550, and 82562 fast ethernet controllers. 
            包含 : fxp.c (與裝置相關), mii.c (與裝置無關)
  lance/    : Ethernet driver for AMD LANCE based ethernet cards. (lance.c)
  libdriver/: Device Independent Device Driver Interface. (driver.c, drvlib.c)
  libpci/    : PCI 插槽 (pci.c, pci_table.c, pci_amd.h, pci_intel.h, pci_via.h, pci.h)
  log/        : system log device (log.c, diag.c, kput.c)
  memory/    : (memory.c)
  printer/    : printer driver. It is a fairly simple driver,supporting only one printer.  
          Characters that are written to the driver are written to the printer without 
          any changes at all.
  random/    : random number generator, (main.c, random.c, sha2.c)
  rescue/    : rescue device driver (rescue.c)
  rtl8138/    : device driver for Realtek rtl8139 based ethernet cards.
  sb16/        : driver for a DSP (Digital Sound Processor) on a SoundBlaster 16 soundcard.
  tty/        : terminal driver (tty.c,  rs232.c, pty.c, keyboard.c, console.c, vidcopy.c)
tools/        : 工具軟體 (Makefile, mkboot, tell_config)
include/    : *.h 的表頭檔 (a.out.h, alloca.h, ansi.h, assert.h, configfile.h, ctype.h, courses.h, 
          dirent.h, env.h, errno.h, fcntl.h, float.h, grp.h, inttype.h, lib.h, libgen.h, 
          libutil.h, limits.h, locale.h, math.h, mathconst.h, netdb.h, pwd.h, regex.h, 
          regexp.h, setjmp.h, sgtty.h, signal.h, stdarg.h, stddef.h, stdint.h, stdio.h, 
          stdlib.h, string.h, tar.h, termcap.h, termios.h, time.h, timers.h, tools.h, ttyent.h, 
          unistd.h, utime.h, utmp.h)
  arpa/        : inet.h
  ibm/        : bios.h, cmos.h, cpu.h, diskparm.h, int86.h, interrupt.h, memory.h, partition.h, 
          portio.h, ports.h
  minix/    : bitmap.h, callnr.h, cdrom.h, com.h, config.h, const.h, devio.h, dl_eth.h, dmap.h, 
          fslib.h, ioctl.h, ipc.h, jmp_buf.h, keymap.h, minlib.h, partition.h, paths.h, 
           sound.h, swap.h, sys_config.h, syslib.h, sysutil.h, type.h, u64.h, 
  net/        : hton.h, if.h, ioctl.h, netlib.h 
    gen/    : arp_io.h, dhcp.h, eth_hdr.h, eth_io.h, ether.h, icmp.h, icmp_hdr.h, if_ether.h, 
          in.h, inet.h, ip_hdr.h, ip_io.h, nameser.h, netdb.h, oneCsum.h, psip_hdr.h, 
          psip_io.h, resolv.h, rip.h, route.h, socket.h, tcp.h, tcp_hdr.h, tcp_io.h, udp.h, 
          udp_hdr.h, udp_io.h, vjhc.h
  netinet/    : in.h, tcp.h
  sys/        : asynchio.h, dir.y, file.h, ioc_cmos.h, ioc_disk.h, ioc_file.h, ioc_memory.h, 
          ioc_scsi.h, ioc_sound.h, ioc_tape.h, ioc_tty.h, ioctl.h, mtio.h, param.h, ptrace.h, 
          resource.h, select.h, sigcontext.h, socket.h, stat.h, statfs.h, svrctl.h, time.h, 
          types.h, uio.h, un.h, utsname.h, wait.h

剖析、編譯、解譯的範例程式 (C# 版)

by ccckmitccckmit 26 Aug 2010 03:06

正則表達式的用法 (取得網頁中的網址) — grep.cs
掃描程式 (Regular Expression 版) — scanner1.cs
掃描程式 (苦力直接判斷版) — scanner2.cs
剖析器 — Parser1.cs, test.parser1.c3, 輸入:test99.parser1.c3
Block 轉 XML 語法的編譯器 — BlockToXmlCompiler.cs, 輸入:EditorMenu.block, 輸出:EditorMenu.xml
很小的 P-Code 編譯器 — Compiler1.cs, Compiler2.cs, 輸入:test99.c3,
很小的 解譯器 — Interpreter1.cs, 輸入:test99.c3
編譯器 — C3Compiler.zip

Mercurial 版本管理與 Google Code

by ccckmitccckmit 19 Aug 2010 00:28

在 Google Code 上提供了兩種版本管理軟體,第一種是集中式的 SVN (SubVersion),第二種是分散式的 Mercurial (Hg),本文使用 Mercurial 進行示範。

Mercurial:修改、儲存、合併

by ccckmitccckmit 18 Aug 2010 09:34

D:\hg>hg clone my-hello my-hello-new-output
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved

D:\hg>cd my-hello-new-output

D:\hg\my-hello-new-output>

將 hello.c 的程式從下列的舊版,用編輯器改為新版。

舊版:hello.c

/*
 * hello.c
 *
 * Placed in the public domain by Bryan O'Sullivan
 *
 * This program is not covered by patents in the United States or other
 * countries.
 */

#include <stdio.h>

int main(int argc, char **argv)
{
    printf("hello, world!\n");
    return 0;
}

新版:hello.c

#include <stdio.h>

int main(int argc, char **argv)
{
    printf("hello, world!\n");
    printf("how are you !\n");
    return 0;
}
D:\hg>cd my-hello-new-output

D:\hg\my-hello-new-output>hg status
M hello.c

D:\hg\my-hello-new-output>hg st
M hello.c

D:\hg\my-hello-new-output>hg diff
diff -r 82e55d328c8c hello.c
--- a/hello.c   Fri Aug 26 01:21:28 2005 -0700
+++ b/hello.c   Wed Aug 18 17:35:28 2010 +0800
@@ -1,16 +1,8 @@
-/*
- * hello.c
- *
- * Placed in the public domain by Bryan O'Sullivan
- *
- * This program is not covered by patents in the United States or other
- * countries.
- */
-
 #include <stdio.h>

 int main(int argc, char **argv)
 {
        printf("hello, world!\n");
+       printf("how are you !\n");
        return 0;
 }

D:\hg\my-hello-new-output>hg revert hello.c

D:\hg\my-hello-new-output>hg st
? hello.c.orig

D:\hg\my-hello-new-output>del hello.c

D:\hg\my-hello-new-output>ren hello.c.orig hello.c

D:\hg\my-hello-new-output>hg st
M hello.c

D:\hg\my-hello-new-output>hg ci
abort: empty commit message
HG: Enter commit message.  Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: ccc kmit <ccc@kmit.edu.tw>
HG: branch 'default'
HG: changed hello.c
D:\hg\my-hello-new-output>hg ci
abort: empty commit message
hello.c : delete comment and insert printf("how are you!");

HG: Enter commit message.  Lines beginning with 'HG:' are removed.
HG: Leave message empty to abort commit.
HG: --
HG: user: ccc kmit <ccc@kmit.edu.tw>
HG: branch 'default'
HG: changed hello.c
D:\hg\my-hello-new-output>hg st

D:\hg\my-hello-new-output>hg par
changeset:   2:fa7474cb125a
tag:         tip
user:        ccc kmit <ccc@kmit.edu.tw>
date:        Wed Aug 18 17:43:32 2010 +0800
summary:     hello.c : delete comment and insert printf("how are you!");

D:\hg\my-hello-new-output>hg log
changeset:   2:fa7474cb125a
tag:         tip
user:        ccc kmit <ccc@kmit.edu.tw>
date:        Wed Aug 18 17:43:32 2010 +0800
summary:     hello.c : delete comment and insert printf("how are you!");

changeset:   1:82e55d328c8c
user:        mpm@selenic.com
date:        Fri Aug 26 01:21:28 2005 -0700
summary:     Create a makefile

changeset:   0:0a04b987be5a
user:        mpm@selenic.com
date:        Fri Aug 26 01:20:50 2005 -0700
summary:     Create a standard "hello, world" program

D:\hg\my-hello-new-output>cd ..

D:\hg>hg clone my-hello my-hello-share
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved

D:\hg>cd my-hello-share

D:\hg\my-hello-share>hg -q tip
1:82e55d328c8c

D:\hg\my-hello-share>cd ..

D:\hg>cd my-hello-new-output

D:\hg\my-hello-new-output>hg -q tip
2:fa7474cb125a

D:\hg\my-hello-new-output>cd ../my-hello-share

D:\hg\my-hello-share>hg pull ../my-hello-new-output
pulling from ../my-hello-new-output
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files
(run 'hg update' to get a working copy)

D:\hg\my-hello-share>hg up
1 files updated, 0 files merged, 0 files removed, 0 files unresolved

D:\hg\my-hello-share>hg pull ../my-hello-new-output
pulling from ../my-hello-new-output
searching for changes
no changes found

D:\hg\my-hello-share>hg push ../my-hello-new-output
pushing to ../my-hello-new-output
searching for changes
no changes found
D:\hg\my-hello-share>hg export tip
# HG changeset patch
# User ccc kmit <ccc@kmit.edu.tw>
# Date 1282124612 -28800
# Node ID fa7474cb125a65a6c0410a627435a6aa8e981958
# Parent  82e55d328c8ca4ee16520036c0aaace03a5beb65
hello.c : delete comment and insert printf("how are you!");

diff -r 82e55d328c8c -r fa7474cb125a hello.c
--- a/hello.c   Fri Aug 26 01:21:28 2005 -0700
+++ b/hello.c   Wed Aug 18 17:43:32 2010 +0800
@@ -1,16 +1,8 @@
-/*
- * hello.c
- *
- * Placed in the public domain by Bryan O'Sullivan
- *
- * This program is not covered by patents in the United States or other
- * countries.
- */
-
 #include <stdio.h>

 int main(int argc, char **argv)
 {
        printf("hello, world!\n");
+       printf("how are you !\n");
        return 0;
 }

D:\hg\my-hello-share>cd ..

D:\hg>hg clone my-hello my-hello-desc
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved

D:\hg>cd my-hello-desc
/*
 * hello.c
 *
 * Placed in the public domain by Bryan O'Sullivan
 *
 * This program is not covered by patents in the United States or other
 * countries.
 */

#include <stdio.h>

int main(int argc, char **argv)
{
    printf("hello, world!\n");
    printf("Nice to meet you! \n");
    return 0;
}
D:\hg\my-hello-desc>hg commit

D:\hg\my-hello-desc>hg pull ../my-hello-new-output
pulling from ../my-hello-new-output
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
(run 'hg heads' to see heads, 'hg merge' to merge)

D:\hg\my-hello-desc>hg heads
changeset:   3:fa7474cb125a
tag:         tip
parent:      1:82e55d328c8c
user:        ccc kmit <ccc@kmit.edu.tw>
date:        Wed Aug 18 17:43:32 2010 +0800
summary:     hello.c : delete comment and insert printf("how are you!");

changeset:   2:f27eee2b7c3b
user:        ccc kmit <ccc@kmit.edu.tw>
date:        Wed Aug 18 17:58:21 2010 +0800
summary:     insert printf("Nice to meet you !");

在 Mercurial.ini 當中加入下列這一行,啟動 graphlog 插件。

[extensions]
hgext.graphlog =
D:\hg\my-hello-desc>hg glog
o  changeset:   3:fa7474cb125a
|  tag:         tip
|  parent:      1:82e55d328c8c
|  user:        ccc kmit <ccc@kmit.edu.tw>
|  date:        Wed Aug 18 17:43:32 2010 +0800
|  summary:     hello.c : delete comment and insert printf("how are you!");
|
| @  changeset:   2:f27eee2b7c3b
|/   user:        ccc kmit <ccc@kmit.edu.tw>
|    date:        Wed Aug 18 17:58:21 2010 +0800
|    summary:     insert printf("Nice to meet you !");
|
o  changeset:   1:82e55d328c8c
|  user:        mpm@selenic.com
|  date:        Fri Aug 26 01:21:28 2005 -0700
|  summary:     Create a makefile
|
o  changeset:   0:0a04b987be5a
   user:        mpm@selenic.com
   date:        Fri Aug 26 01:20:50 2005 -0700
   summary:     Create a standard "hello, world" program

D:\hg\my-hello-desc>hg update
abort: crosses branches (use 'hg merge' or use 'hg update -c')

D:\hg\my-hello-desc>hg parents
changeset:   2:f27eee2b7c3b
user:        ccc kmit <ccc@kmit.edu.tw>
date:        Wed Aug 18 17:58:21 2010 +0800
summary:     insert printf("Nice to meet you !");

D:\hg\my-hello-desc>hg merge
merging hello.c
warning: conflicts during merge.
merging hello.c failed!
0 files updated, 0 files merged, 0 files removed, 1 files unresolved
use 'hg resolve' to retry unresolved file merges or 'hg update -C' to abandon

[[code]]
#include <stdio.h>

int main(int argc, char **argv)
{
printf("hello, world!\n");
«««< local
printf("Nice to meet you! \n");

Mercurial:檢視 log

by ccckmitccckmit 18 Aug 2010 09:28

[[code]]
D:\hg>cd my-hello

Mercurial 版本管理工具的使用方法

by ccckmitccckmit 18 Aug 2010 05:58

Mercurial 的中文意思如下:

Mercurial 版本管理工具的安裝與設定

by ccckmitccckmit 18 Aug 2010 05:53

在分散式版本管理上,Mercurial 與 git 是兩個常見的版本管理系統,Mercurial 是由 Matt Mackal 所創建的,而 git 則是由 Linux 的創造者 Linus Tovards 所創建的。

版本管理工具簡介

by ccckmitccckmit 18 Aug 2010 05:50

以下是軟體專案管理常用的版本管理工具,其中 CVS (Concurrent Version System) 是較早期使用的版本管理工具,但也常產生一些管理上的問題,因此後來多被 SVN (Sub Version)。這兩個版本管理工具採用集中式的作法,因此比較適合集中式統一版本的「大教堂式專案開發模式」,但是對於像是 Linux 這樣採用較彈性的分散式開發模式而言,就不太適用了。有鑑於此,Linux 的作者 Linus Tovards 自己開發了 git 這個版本管理軟體,採用分散式的模式。而幾乎與 Tovards 同時,Matt Mackal 也發現了這個問題,因此利用 Python 撰寫了另一個分散式版本管理軟體 Mercurial,這個軟體被用在 Google Code 的網站伺服器上,與 SVN 成為 Google Code 的兩個選擇之一。

Mercurial 版本管理的基本概念

by ccckmitccckmit 18 Aug 2010 01:39

版權聲明:本文內容與圖片部分來自 http://mercurial.selenic.com/quickstart/,該網頁為 GPLv2 授權,因此修改使用時請遵守 GPL 第二版的授權協議。

Test -- CPU0 工具鏈的測試範例

by ccckmitccckmit 13 Aug 2010 00:42

sum = 0;
for (i=0; i<=10; i++)
{
  sum = sum + i;
}
return sum;

Makefile -- CPU0 工具鏈的專案建置檔

by ccckmitccckmit 13 Aug 2010 00:32

[[code]]
CC = gcc.exe -DDEBUG
OBJ = Parser.o Tree.o Lib.o Scanner.o Array.o Compiler.o HashTable.o Generator.o Assembler.o Cpu0.o OpTable.o
LINKOBJ = $(OBJ)
LIBS =
INCS =
BIN = test.exe c0c.exe as0.exe vm0.exe
CFLAGS = $(INCS) -g3
RM = rm -f

OpTable -- CPU0 的指令表

by ccckmitccckmit 13 Aug 2010 00:29

[[code]]
#ifndef OPTABLE_H
#define OPTABLE_H

Main -- CPU0 工具鏈的主程式

by ccckmitccckmit 13 Aug 2010 00:26

[[code]]
#include "Assembler.h" // 引用組譯器檔頭
#include "Compiler.h" // 引用編譯器檔頭

Compiler -- 編譯器 (將 C0 程式編譯為 CPU0 的組合語言)

by ccckmitccckmit 13 Aug 2010 00:23

[[code]]
#ifndef COMPILER_H

Tree -- 多元樹 (作為 C0C 編譯器的語法樹)

by ccckmitccckmit 13 Aug 2010 00:20

[[code]]
#ifndef TREE_H
#define TREE_H

Generator -- 將語法樹轉換為 CPU0 的組合語言

by ccckmitccckmit 13 Aug 2010 00:13

[[code]]
#ifndef GENERATOR_H
#define GENERATOR_H

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License