2010/07/22

linux v0.01's switch_to macro.

I read a source code that is switch_to macro in linux kernel v0.01. This version of switch_to macro is different from current one. It used hardware context switching instead of software context switching. Although, it's quite easy to understand how it works.

You can see the source code at LEX and the switch_to macro is in include/linux/sched.h.

168#define switch_to(n) {\
 169struct {long a,b;} __tmp; \
 170__asm__("cmpl %%ecx,_current\n\t" \
 171        "je 1f\n\t" \
 172        "xchgl %%ecx,_current\n\t" \
 173        "movw %%dx,%1\n\t" \
 174        "ljmp %0\n\t" \
 175        "cmpl %%ecx,%2\n\t" \
 176        "jne 1f\n\t" \
 177        "clts\n" \
 178        "1:" \
 179        ::"m" (*&__tmp.a),"m" (*&__tmp.b), \
 180        "m" (last_task_used_math),"d" _TSS(n),"c" ((long) task[n])); \
This is the switch_to macro at all. It's simple isn't it?
It is called from schedule() like switch_to(next);. next is an index number to next process in the array of task it data type is struct task_struct.

At line 169, temporary structure is defined which need to segment jump. Line 170 is comparing ecx register to current process. btw, in assembly code, "_" prefix is needed. Anyway, why it uses ecx register means at line 180 you can see "c" ((long) task[n]) statement. It means the address of task[n] is copied to ecx register. so, it can use ecx register to comparing.
Then if current process and next process is same, jump to line 178 and finish this macro. If current process != next process, current process is copied to ecx register.
At line 173, edx register's value is copied to __tmp.b. Then do segment jump at line 174. Then process was switched to new process because linux v0.01 uses hardware context switch so that segment jump via TSS segment cause task switching.
Next, at line 175 checks if current is same as last_task_used_math. The last_task_used_math has FPU registers state. If current == last_task_used_math, it call clts instruction to clear TS flag in CR0 register. From intel's ducument, it says The processor sets the TS flag every time a task switch occurs. The flag is used to synchronize the saving of FPU context in
multitasking applications
. Then everything is done:-)

2010/07/20

memo: do_fork()

Flow of switching a process address space.
do_fork() @kernel/fork.c
|-> copy_process() @kernel/fork.c
   |-> copy_mm() @kernel/fork.c
       |-> dup_mm() @kernel/fork.c
           |-> mm_init() @kernel/fork.c
               |-> mm_alloc_pgd() @kernel/fork.c
                   |-> pgd_alloc() @arch/x86/mm/pgtable.c

2010/07/14

What is the .treeinfo

When I was reading some test cases, I thought where the .treeinfo is. I check install disk but there were no .treeinfo. so I googled it then I got where the .treeinfo is.
It in "/somedirectory/x86_64/os/.treeinfo" you mayn't see it from web browser or ftp client because ftp server won't show dot file. however, if you enter the url directory, you'll be able to see it.

2010/07/08

proven tester

I was approved to Fedora proven tester group:-) I'll do my best.
I hope I can help to making Fedora release better. anyway, I need to learn a lot about whole fedora's features, critical path pakcages feathers and so forth.

2010/07/05

memo: boot option

This is my memo to pass boot option to anaconda.
There is two ways to enter boot option.
1. add repo=<host>/Linux/fedora/releases/13/Fedora/x86_64/os/images/
This option get install.img from the URL.

2. add askmethod
This option ask you to where to get install.img from(e.g. http, nfs and so on).

2010/07/03

Testing rawhide.

I submitted three bug reports against rawhide today.

The reports are following URLs.
#611037
#611073
#611083

AFAIK, run a program from terminal emulator is good way to test. cuz, if run a program from an icon or likewise, it may works fine but sometimes error message is shown at stderr or stdout.
If you run a program via an icon, you won't miss to see an error messages. so I think run a program both way is useful.

2010/07/01

Bug report 2010/07/01

I reported it today.
https://bugzilla.redhat.com/show_bug.cgi?id=610087

It summary is qemu-kvm chrash. I have some fedora images e.g. FC13, rawhide. but I only had this happen while I was running FC13 image.
I could reproduce sometimes but I don't know what is the cause of the crash:-(