2010年1月7日 星期四

Jesse Livermore語錄(1)


"There is nothing new in Wall Street. There can't be because speculation is as old as the hills. Whatever happens in the stock market today has happened before and will happen again."
華爾街未曾改變,財富來來去去,股票起起落落,但華爾街永遠沒變,因為人性永遠不會改變。
相信大家從去年的3955到去年的最後一天8188有著很深的感觸吧,當跌到谷底的時候,即便你想再跌也差不多了,就是不敢進去,到了年底,想說再漲應該也有限了吧(即便上萬,也只剩不到2000點),但是,在3955的時候,每個人心中只有恐懼,敢買的人有限,敢一口氣抱到年底的更是少數(電子股很多都漲超過5倍了),到了年底,8188之上,每個人的貪婪與無知,將自己推往股市,人性真的沒變過阿。
不斷的重複著貪婪、恐懼、無知、希望,所以市場重複著相同的結構與步驟,這一切的一切都是源自於人性

每個人都知道低買高賣,但是殺到後來你敢買嗎?
每個人都知道不可追高殺低,但是漲到你忍不住,你還是買了
耐心等到,是賺錢的不二法則,卻也是一種高深的修養


2010年1月5日 星期二

Linux Kernel(9)- Kthread


在kernel中建立thread可以使用kthread_create(),建立一個task,然後在調用wake_up_process(task)讓task真正的運行,如果要kill一個kthread可以使用kthread_stop()。
在kernel中,將kthread_create()和wake_up_process()包裝成kthread_run(),也就是調用了kthread_run()之後,該thread會立刻被執行。
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kthread.h>

MODULE_LICENSE("GPL");

static struct task_struct *brook_tsk;
static int data;
static int kbrook(void *arg);

static int kbrook(void *arg)
{
    unsigned int timeout;
    int *d = (int *) arg;

    for(;;) {
        if (kthread_should_stop()) break;
        printk("%s(): %d\n", __FUNCTION__, (*d)++);
        do {
            set_current_state(TASK_INTERRUPTIBLE);
            timeout = schedule_timeout(10 * HZ);
        } while(timeout);
    }
    printk("break\n");

    return 0;
}

static int __init init_modules(void)
{
    int ret;

    brook_tsk = kthread_create(kbrook, &data, "brook");
    if (IS_ERR(brook_tsk)) {
        ret = PTR_ERR(brook_tsk);
        brook_tsk = NULL;
        goto out;
    }
    wake_up_process(brook_tsk);

    return 0;

out:
    return ret;
}

static void __exit exit_modules(void)
{
    kthread_stop(brook_tsk);
}

module_init(init_modules);
module_exit(exit_modules);


linux/kthread.h
/**
 * kthread_run - create and wake a thread.
 * @threadfn: the function to run until signal_pending(current).
 * @data: data ptr for @threadfn.
 * @namefmt: printf-style name for the thread.
 *
 * Description: Convenient wrapper for kthread_create() followed by
 * wake_up_process().  Returns the kthread or ERR_PTR(-ENOMEM).
 */
#define kthread_run(threadfn, data, namefmt, ...)      \
({            \
 struct task_struct *__k         \
  = kthread_create(threadfn, data, namefmt, ## __VA_ARGS__); \
 if (!IS_ERR(__k))         \
  wake_up_process(__k);        \
 __k;           \
})


2010年1月4日 星期一

ubuntu package - bind9-host


host主要拿來作DNS的lookup,和nslookup一樣,可以作正解(lookup/由domain name找到IP),也可以作反解(reverse lookup/由IP找到domain name),大多數的User比較常接觸到的是正解。
brook@ubuntu:~$ host dns.hinet.net
dns.hinet.net has address 168.95.1.1
brook@ubuntu:~$ 
brook@ubuntu:~$ host 168.95.1.1
1.1.95.168.in-addr.arpa domain name pointer dns.hinet.net.
brook@ubuntu:~$ 
brook@ubuntu:~$ host www.google.com
www.google.com is an alias for www.l.google.com.
www.l.google.com has address 72.14.203.99
www.l.google.com has address 72.14.203.147
www.l.google.com has address 72.14.203.104
www.l.google.com has address 72.14.203.103
www.l.google.com has address 72.14.203.105
www.l.google.com has address 72.14.203.106
brook@ubuntu:~$ 
brook@ubuntu:~$ host 72.14.203.99
99.203.14.72.in-addr.arpa domain name pointer tx-in-f99.1e100.net.

建議參考資料︰
  http://linux.vbird.org/linux_server/0350dns.php
  http://plog.longwin.com.tw/news_security/2005/11/06/dns_error_top_3

熱門文章