2009년 12월 30일 수요일

덕재의 부탁 ㅋ

충남대,,

 

한국 기술대

3학년 2학기..

성적이 다 나왓다. 흑흑..

 

열심이 한거 같은데. ㅋㅋ 머야 이건 샹.. 울고 싶다 부모님께 죄송하다 ㅎㅎ

 

평점 3.4  이건 머 ㅋㅋ

 

잘한건가? ㅋㅋ      실험이 c+이 나오고 아오...

 

그래도 이번 겨울 방학때 열심이 해야지요 ㅋ 토익 아자!!  650 ㄱㄱㄱ

2009년 12월 22일 화요일

언어교육원

강사님  블로그.

http://blog.naver.com/judy1243


usb로 윈도우 설치하기

http://www.ihg.co.kr/menu/customer-index.php?mode=view&bi=10&table=joo_board_10&cP=1&uid=55&gid=55&queryNum=0&cuid=70&ssPrevUid=&ssNextUid=&bcate=0&searchKey=&searchType=&cSearch=&page_number_list=70&thread=A

노트북 사자!

1.

2.
2.
한성컴퓨터 SPARQ SL30

AMD / 셈프론 / 210U (1.5GHz) / LED 백라이트 / 13.3인치 / 1280x800 / 320GB / 2GB / 옵션(선택사항) / 미포함 / AMD(ATI) / 라데온 X1270 / 시스템 메모리 공유 / 1.79Kg / 6cell / 802.11n 무선랜 / HDMI / D-SUB / 웹캠 / 멀티 리더기 / 울트라씬 / 색상: 화이트

4.
MSI WIND NB U210X-Prime 1

AMD / 애슬론 네오 / MV-40 (1.6GHz) / LED 백라이트 / 12.1인치 / 1366x768 / 250GB / 2GB / 옵션(선택사항) / 미포함 / AMD(ATI) / 라데온 X1270 / 시스템 메모리 공유 / 1.39Kg / 6cell / 1Gbps 유선랜 / 802.11n 무선랜 / HDMI / D-SUB / 웹캠 / 블루투스 / 얼굴 인식 / 멀티 리더기 / 울트라씬 / 색상: 블랙, 화이트


5.

MSI WIND NB U200X Longrun (ULV 723)

인텔 / 셀러론M / ULV 723 (1.2 GHz) / LED 백라이트 / 12.1인치 / 1366x768 / 250GB / 2GB / 옵션(선택사항) / 미포함 / 인텔 / GMA 4500MHD / 시스템 메모리 공유 / 1.39Kg / 6cell / 1Gbps 유선랜 / 802.11n 무선랜 / HDMI / D-SUB / 웹캠 / 얼굴 인식 / 멀티 리더기 / 울트라씬 / 색상: 블랙, 화이트



6.

MSI WIND NB U210 

AMD / 애슬론 네오 / MV-40 (1.6GHz) / LED 백라이트 / 12.1인치 / 1366x768 / 160GB / 1GB / 옵션(선택사항) / XP Home / AMD(ATI) / 라데온 X1270 / 시스템 메모리 공유 / 1.39Kg / 6cell / 1Gbps 유선랜 / 802.11n 무선랜 / HDMI / D-SUB / 웹캠 / 블루투스 / 얼굴 인식 / 멀티 리더기 / 울트라씬 / 색상: 블랙, 화이트


7.

MSI WIND NB U200X Longrun Fresh (SU2300)

인텔 / 셀러론 듀얼코어 / SU2300 (1.2GHz) / LED 백라이트 / 12.1인치 / 1366x768 / 320GB / 2GB / 옵션(선택사항) / 미포함 / 인텔 / GMA 4500MHD / 시스템 메모리 공유 / 1.39Kg / 6cell / 1Gbps 유선랜 / 802.11n 무선랜 / HDMI / D-SUB / 웹캠 / 얼굴 인식 / 멀티 리더기 / 울트라씬 / 색상: 블랙, 화이트


2009년 12월 21일 월요일

이차원 배열 할당 하기!!

uchar** mem_Allocate(int row, int col)
{
uchar **p;
int i;

// store to original image
p = (uchar**)calloc(row, sizeof(char*));  // allocate for store pointer
p[0] = (uchar*)calloc(row*col, sizeof(char)); // 0th index allocate 512*512
for(i = 1; i<row; i++) // pointer value store to "i"th index
p[i] = p[i-1] + col;
return p;
}

이렇게 하면 해제가 아주간단하다.

free(p[0]);
free(p);

그리고 파일을 읽어 올때도 fread()함수를 이용해서 한번에 읽어 올수 있다

2009년 12월 2일 수요일

struct mm_struct

194 struct mm_struct {
195     struct vm_area_struct * mmap;       /* list of VMAs */
203     unsigned long task_size;        /* size of task vm space */


227     unsigned long total_vm, locked_vm, shared_vm, exec_vm;
228     unsigned long stack_vm, reserved_vm, def_flags, nr_ptes;
229     unsigned long start_code, end_code, start_data, end_data;
230     unsigned long start_brk, brk, start_stack;
231     unsigned long arg_start, arg_end, env_start, env_end;
}

 

126 struct vm_area_struct {
127     struct mm_struct * vm_mm;   /* The address space we belong to. */
128     unsigned long vm_start;     /* Our start address within vm_mm. */
129     unsigned long vm_end;       /* The first byte after our end address
}

한울장학금 신청하기

상수가 써주었다. ㅋㅋ

 

어려운 경제 난 속에 가정 형편이 어려워서 이렇게 한울 장학금을 신청 하게 되었습니

 

다. 간단히 저희 집을 소개하고자 합니다. 저희 집은 3형제로 농사를 짓고 계시는 아

 

버지와 어머니 그리고 몸이 불편하여 장애인 판정을 받은 둘째 동생 그리고 저와 또

 

한명의 동생이 있습니다. 저와 동생은 몸이 불편하고 힘든 환경 속에서도 성적 장학금

 

을 받기 위해서 학업에 열심히 매진하였습니다. 하지만 식비를 충당하기 위해 방과 후

 

아르바이트와 주말 아르바이트 등으로 학업에 매진할 수 없었습니다. 그 결과 2학년

 

때는 좋은 성적으로 장학금을 받았던 그 성적이 3학년 1학기에 와서는 결국 평균정도

 

의 성적 밖에 받지 못했습니다. 그리고 이번에는 막내 동생까지 대학생이 되었고 어머

 

니와 아버지께서 하시는 농사는 흉년이라 학교를 다니기 힘들 정도로 어려워 졌습니

 

다. 저는 정말 공부가 너무 하고 싶고 열정이 있습니다. 어떤 어려운 환경도 이겨 낼

 

수 있을 것이라 생각 하고 있습니다. 하지만 이번만큼은 너무 힘들어서 하루하루 고민

 

의 날들로 보내고 있습니다. 이런 열정이 있는 저에게 공부할수 있는 조금에 희망을

 

주셨으면 좋겟습니다. 한울장학금을 받게되어 학업에 매진할수 있다면 저의 열정으로

 

광운학교의 위상을 높게 세우고 싶습니다. 이런저에게 기회를 주셨으면 좋겟습니다.

2009년 11월 26일 목요일

3 by 3 matrix 역행렬 구하기

3by3행렬 A =


(a11 a12 a13
a21 a22 a23
a31 a32 a33


라고 할때, 행렬식은

det(A) = a11*(a22*a33 - a23*a32) -a12*(a21*a33 - a23*a31) + a13*(a21*a32 -
a22*a31)


a1행의 열들의 성분을 선두로 정리하면

A = a11*det(M11) - a12*det(M12) + a13*det(M13)

여기서 Mij :

ij위치의 값을 제외한 소행렬


이것으로 Aij의 여인자값 Cij = ((-1)^(i+j)) * det(Mij) 을 구할 수 있고,

이 여인자 값들로 여인자 행렬 C를 구할 수 있다.


C =


(C11 C12 C13
C21 C22 C23
C31 C32 C33)
=


det(M11) -det(M12) det(M13)

-det(M21) det(M22) -det(M23)

det(M31) -det(M32) det(M33)


여인자 행렬의 전치행렬 transpose(C) = adj(A) 라고 하고, 수반행렬이라고 부른다.

전치라는 말을 풀어보면 Aij에서 핸과 열을 바꾼
Aji를 의미한다.

역행렬 A` = ( 1/det(A) ) * adj(A) 로 구할 수 있다.


A의 여인자 행렬 C를 구하고

이것의 행렬의 성분 ij위치를 ji로 바꾸는 것이다.

즉 a11은 a11 그대로 위치이고

a12는 a21이 되면서 위치가 바뀌고,

a13은 a31,

a21은 a12, . . .

a32는 a23,

a33은 a33 위치로 바뀌는 것이다.


정리해보자면 A의 여인자 행렬 C =

|

(a22*a33 - a23*a32) -(a21*a33 - a23*a31) (a21*a32 - a22*a31)

-(a12*a33 - a13*a32) (a11*a33 - a13*a31) -(a11*a32 - a12*a31)

(a12*a23 - a13*a22) -(a11*a23 - a13*a32) (a11*a22 - a12*a21)

|


이며, A의 전치행렬 adj(A) =

|

(a22*a33 - a23*a32) -(a12*a33 - a13*a32) (a12*a23 - a13*a22)

-(a21*a33 - a23*a31) (a11*a33 - a13*a31) -(a11*a23 - a13*a32)

(a21*a32 - a22*a31) -(a11*a32 - a12*a31) (a11*a22 - a12*a21)

|


이므로 (1/det(A) ) * adj(A) = A` 으로 역행렬을 구할 수 있다.


자, 이제는 예제를 하나 만들어 풀어보자.


A = (1 2 3
0 1 0
2 3 1)


의 역행렬을 구해보자.



det(A)=(1 2 3
0 1 0
2 3 1)


A 행렬값을 구하기 위해

여인자 전개를 사용하기 위해서

무조건 윗 식을 그대로 사용하기 전에

선두에 오는 값이 되도록 0이거나 그에 가까운 숫자가 많은 행을 선택하는 것이 행렬값을 빨리 풀 수 있다.

그래서 선두 행을 2 행으로 정하고 풀어 보겠다.


det(A) =0*c1 + 1*c2 + 0*c3

여기서 c1과 c3은 구할 필요가 없다.

어차피 0이 되므로.


c2 = (-1)^(2+2) * |1 3
2 1|
= -5


고로 det(A)=1*(-5)= -5 가 구하는 값이다.


전치행렬 adj(A) 를 구하자.

|

(a22*a33 - a23*a32) -(a12*a33 - a13*a32) (a12*a23 - a13*a22)

-(a21*a33 - a23*a31) (a11*a33 - a13*a31) -(a11*a23 - a13*a32)

(a21*a32 - a22*a31) -(a11*a32 - a12*a31) (a11*a22 - a12*a21)

|


=

|

(1*1 - 0) -(2*1 -3*3) (2*0 - 3*1)

-(0 - 0) (1*1 - 3*2) -(1*0 - 0)

(0 - 1*2) -(1*3 - 2*2) (1*1 - 0)

|


=

(

1 7 -3

0 -5 0

-2 1 1

)


자 이제

A*A~ = I 가 되는지 살펴보자.


(1 2 3
0 1 0
2 3 1)


*


(1 7 -3
0 -5 0
-2 1 1)


* -(1/5)

=


i11=1*1+2*0+3*(-2) = -5

i12=1*7+2*(-5)+3*1=0

i13=1*(-3)+0+3*1=0

i21=0+0+0= 0

i22=0-5+0 = -5

i23=0+0+0= 0

i31=2*1+01*(-2)= 0

i32=2*7+3*(-5)+1*1= 0

i33=2*(-3)+0+1*1 = -5


I = (-1/5) * i = 1

고로

전치행렬과 det(A)를 곱하고 A를 곱하면
단위행렬 I가 만들어짐을 알 수 있을것이다.

그러므로

역행렬 A~은


-(1/5) * |1 7 -3
0 -5 0
-2 1 1)


이다.

참고한 site는
http://kin3d.net/tt/index.php?page=7&md=pl&PHPSESSID=2d9586c49a90fb29ac252dfaa55
6b80f


입니다.

송운배 http://kr.geocities.com/hmac62

2009년 11월 23일 월요일

vi 에디터에서 치환 명령어

 

:%s/찾는단어/바꿀단어
문서 전체의 "찾는단어"가 바꿀단어"로 치환된다.

 

:s/찾는단어/바꿀단어
현재 커서가 위치하고 있는 줄의 1번째 "찾는단어"만 "바꿀단어"로 치환된다

2009년 11월 22일 일요일

리눅스에서 초세기

리눅스에서는 1/Hz 초마다 증가하는 jiffies 라는 커널전역변수가 존재 한다.

 

그러므로 jiffies/HZ는 초단위가  된다??

바람 끼 테스트 ㅎㅎ

 

http://home.postech.ac.kr/~heyguys/pds/html/dungen.swf

 

난. 이렇게 나오네 ㅎㅎ

근데. 아직 연애를 못해 봤다는거..

 

 

2009년 11월 19일 목요일

struct rt_rq

  486 /* Real-Time classes' related field in a runqueue: */
  487 struct rt_rq {
  488     struct rt_prio_array active;
  489     unsigned long rt_nr_running;
  490 #if defined CONFIG_SMP || defined CONFIG_RT_GROUP_SCHED
  491     struct {
  492         int curr; /* highest queued rt task prio */
  493 #ifdef CONFIG_SMP
  494         int next; /* next highest */
  495 #endif
  496     } highest_prio;
  497 #endif
  498 #ifdef CONFIG_SMP
  499     unsigned long rt_nr_migratory;
  500     unsigned long rt_nr_total;
  501     int overloaded;
  502     struct plist_head pushable_tasks;
  503 #endif
  504     int rt_throttled;
  505     u64 rt_time;
  506     u64 rt_runtime;
  507     /* Nests inside the rq lock: */
  508     spinlock_t rt_runtime_lock;
  509
  510 #ifdef CONFIG_RT_GROUP_SCHED
  511     unsigned long rt_nr_boosted;
  512
  513     struct rq *rq;
  514     struct list_head leaf_rt_rq_list;
  515     struct task_group *tg;
  516     struct sched_rt_entity *rt_se;
  517 #endif

  518 };

struct cfs_rq

  423 /* CFS-related fields in a runqueue */
  424 struct cfs_rq {
  425     struct load_weight load;
  426     unsigned long nr_running;
  427
  428     u64 exec_clock;
  429     u64 min_vruntime;
  430
  431     struct rb_root tasks_timeline;
  432     struct rb_node *rb_leftmost;
  433
  434     struct list_head tasks;
  435     struct list_head *balance_iterator;
  436
  437     /*
  438      * 'curr' points to currently running entity on this cfs_rq.
  439      * It is set to NULL otherwise (i.e when none are currently running).
  440      */
  441     struct sched_entity *curr, *next, *last;
  442
  443     unsigned int nr_spread_over;
  444
  445 #ifdef CONFIG_FAIR_GROUP_SCHED
  446     struct rq *rq;  /* cpu runqueue to which this cfs_rq is attached */
  447
  448     /*
  449      * leaf cfs_rqs are those that hold tasks (lowest schedulable entity in
  450      * a hierarchy). Non-leaf lrqs hold other higher schedulable entities
  451      * (like users, containers etc.)
  452      *
  453      * leaf_cfs_rq_list ties together list of leaf cfs_rq's in a cpu. This
  454      * list is used during load balance.
  455      */
  456     struct list_head leaf_cfs_rq_list;
  457     struct task_group *tg;  /* group that "owns" this runqueue */
  458
  459 #ifdef CONFIG_SMP
  460     /*
  461      * the part of load.weight contributed by tasks
  462      */
  463     unsigned long task_weight;
  464
  465     /*
  466      *   h_load = weight * f(tg)
  467      *
  468      * Where f(tg) is the recursive weight fraction assigned to
  469      * this group.
  470      */
  471     unsigned long h_load;
  472
  473     /*
  474      * this cpu's part of tg->shares
  475      */
  476     unsigned long shares;
  477
  478     /*
  479      * load.weight at the time we set shares
  480      */
  481     unsigned long rq_weight;
  482 #endif
  483 #endif
  484 };

 

2009년 11월 17일 화요일

혈관고 - 돌도 도는 관계

ㅎㅎ

vm_area_struct

include/linux/mm_types.h

126 struct vm_area_struct {
127     struct mm_struct * vm_mm;   /* The address space we belong to. */
128     unsigned long vm_start;     /* Our start address within vm_mm. */
129     unsigned long vm_end;       /* The first byte after our end address
130                        within vm_mm. */
131
132     /* linked list of VM areas per task, sorted by address */
133     struct vm_area_struct *vm_next;
134
135     pgprot_t vm_page_prot;      /* Access permissions of this VMA. */
136     unsigned long vm_flags;     /* Flags, see mm.h. */
137
138     struct rb_node vm_rb;
139
140     /*
141      * For areas with an address space and backing store,
142      * linkage into the address_space->i_mmap prio tree, or
143      * linkage to the list of like vmas hanging off its node, or
144      * linkage of vma in the address_space->i_mmap_nonlinear list.
145      */
146     union {
147         struct {
148             struct list_head list;
149             void *parent;   /* aligns with prio_tree_node parent */
150             struct vm_area_struct *head;
151         } vm_set;
152
153         struct raw_prio_tree_node prio_tree_node;
154     } shared;
155
156     /*

157      * A file's MAP_PRIVATE vma can be in both i_mmap tree and anon_vma
158      * list, after a COW of one of the file pages.  A MAP_SHARED vma
159      * can only be in the i_mmap tree.  An anonymous MAP_PRIVATE, stack
160      * or brk vma (with NULL file) can only be in an anon_vma list.
161      */
162     struct list_head anon_vma_node; /* Serialized by anon_vma->lock */
163     struct anon_vma *anon_vma;  /* Serialized by page_table_lock */
164
165     /* Function pointers to deal with this struct. */
166     struct vm_operations_struct * vm_ops;
167
168     /* Information about our backing store: */
169     unsigned long vm_pgoff;     /* Offset (within vm_file) in PAGE_SIZE
170                        units, *not* PAGE_CACHE_SIZE */
171     struct file * vm_file;      /* File we map to (can be NULL). */
172     void * vm_private_data;     /* was vm_pte (shared mem) */
173     unsigned long vm_truncate_count;/* truncate_count or restart_addr */
174
175 #ifndef CONFIG_MMU
176     struct vm_region *vm_region;    /* NOMMU mapping region */
177 #endif
178 #ifdef CONFIG_NUMA
179     struct mempolicy *vm_policy;    /* NUMA policy for the VMA */
180 #endif
181 };

2009년 11월 15일 일요일

강지영

스모하는 상수

지못미

진호

ㅎㅎ

 

넥타이 메기!

 

넥타이 메기1

 

 

 

넥타이 메기2

grep

grep -r foo *
서브디렉토리까지 foo 라는 문자열 찾기

cpu정보출력하기

$cat /proc/cpuinfo

processor       : 0
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 104
model name      : AMD Athlon(tm) 64 X2 Dual Core Processor TK-55
stepping        : 1
cpu MHz         : 1807.720
cache size      : 256 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt lm 3dnowext 3dnow pni cx16 lahf_lm ts fid vid ttp tm stc [6]
bogomips        : 3620.12
clflush size    : 64

processor       : 1
vendor_id       : AuthenticAMD
cpu family      : 15
model           : 104
model name      : AMD Athlon(tm) 64 X2 Dual Core Processor TK-55
stepping        : 1
cpu MHz         : 1807.720
cache size      : 256 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 1
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx mmxext fxsr_opt lm 3dnowext 3dnow pni cx16 lahf_lm ts fid vid ttp tm stc [6]
bogomips        : 3679.70
clflush size    : 64

듀얼 코어라서 그런지 두개가 나온다.  ㅎㅎ

2009년 11월 14일 토요일

task_struct

커널 버전 2.6.20.18

sched.h

 

 801 struct task_struct {
 802     volatile long state;    /* -1 unrunnable, 0 runnable, >0 stopped */

 

 816     int prio, static_prio, normal_prio;  // 우선순위
 831     unsigned int time_slice, first_time_slice;  //


 887     unsigned long nvcsw, nivcsw; /* context switch counts */

 888     struct timespec start_time; // 프로세스 생성시간?

 896 /* process credentials */
 897     uid_t uid,euid,suid,fsuid;
 898     gid_t gid,egid,sgid,fsgid;

 918     char comm[TASK_COMM_LEN]; /* executable name excluding path
 919                      - access with [gs]et_task_comm (which lock
 920                        it with task_lock())
 921                      - initialized normally by flush_old_exec */

spin lock

 

spin lock은 mutiprocessor system에서
여러 processor가 동시에 critical section에 진입하지 못하도록 하는 synchronization 기법이다.
한 processor가 lock을 가지고 있으면 다른 processor들은 unlock될 때까지 busy-wait하다가
lock을 차지하기 위해 동시에 lock 변수에 접근(write)한다.

여기서 두 가지 문제가 발생할 수 있는데
첫 번째는 각 processor 간에 lock을 획득하는 순서를 보장할 수 없기 때문에
먼저 spin lock을 기다리던 processor가 더 나중에 lock을 얻을 수도 있다는 것이다.
때문에 spin lock은 공정하지 못하다.

또 하나의 문제는 성능에 관련된 것으로
cache coherency로 인해 한 processor가 lock 변수에 write를 하게되면
다른 모든 processor의 cache line이 invalidate된다.
따라서 contention이 심한 경우 lock을 얻은 processor에서도 반복적으로 cache miss가 발생하여
실행 성능이 매우 나빠질 수 있다. (보통 lock 변수와 데이터는 같은 line에 놓여있을 것이다.)

ticket spin lock은 이를 개선하기 위해 2.6.25 버전부터 도입된 것으로
lock을 기다리는 각 processor들은 자신 만의 ticket을 부여받고
자기 차례가 돌아오는 경우에만 write를 시도하므로
순서대로 lock을 얻을 수 있으며 전체적으로 cache miss 횟수를 줄일 수 있다.

 


 

박세준 - 거짓말 [가사]

세상에 안되는 게 있다죠
한 사람 사랑하는 마음과
미워하는 마음 깊이 숨길순 없나봐요

그대가 지금 다가오네요
난 그저 외면하려 하네요
내 마음은 이미 그대 안에 있는데

많이 모자란 내게
넘치는 사랑을 주고
어설픈 나의 농담에
너무 큰 소리로 웃어 주네요

그대 잠시 쉬어 가도 되요
그대 그냥 스쳐 가도 되요
지금 그대의 그 자린 항상 비었었기에
난 괜찮아요

많이 모자란 내게
넘치는 사랑을 주고
어설픈 나의 농담에
너무 큰 소리로 웃어 주네요

그대 잠시 쉬어 가도 되요
그대 그냥 스쳐 가도 되요
지금 그대의 그 자린 항상 비었었기에
난 괜찮아요

그대여
나는 거짓말을 하네요
그대 없인 난

그대 잠시 쉬어 가지 말아요
그대 그냥 스쳐 가진 말아요
지금 그대의 그 자릴 비우지 말아줘요
언제까지나

세상엔 너무 힘든게 있죠
한 사람 깊이 사랑할 수록
날 위해서 항상 이별을 준비해야
한다는 걸

context switching

sched.c

 

1835 /*
1836  * context_switch - switch to the new MM and the new
1837  * thread's register state.
1838  */

 

1839 static inline struct task_struct *
1840 context_switch(struct rq *rq, struct task_struct *prev,
1841            struct task_struct *next)
1842 {
1843     struct mm_struct *mm = next->mm;
1844     struct mm_struct *oldmm = prev->active_mm;
1845
1846     if (!mm) {
1847         next->active_mm = oldmm;
1848         atomic_inc(&oldmm->mm_count);
1849         enter_lazy_tlb(oldmm, next);
1850     } else
1851         switch_mm(oldmm, mm, next);
1852
1853     if (!prev->mm) {
1854         prev->active_mm = NULL;
1855         WARN_ON(rq->prev_mm);
1856         rq->prev_mm = oldmm;
1857     }
1858     /*
1859      * Since the runqueue lock will be released by the next
1860      * task (which is an invalid locking op but in the case
1861      * of the scheduler it's an obvious special-case), so we
1862      * do an early lockdep release here:
1863      */
1864 #ifndef __ARCH_WANT_UNLOCKED_CTXSW
1865     spin_release(&rq->lock.dep_map, 1, _THIS_IP_);
1866 #endif
1867
1868     /* Here we just switch the register state and the stack. */
1869     switch_to(prev, next, prev);
1870
1870
1871     return prev;
1872 }

jiffies

$pwd

/usr/src/linux-2.6.20.18

$vi drivers/md/raid6.h

117 # define jiffies    raid6_jiffies()


130 static inline uint32_t raid6_jiffies(void)
131 {
132     struct timeval tv;
133     gettimeofday(&tv, NULL);
134     return tv.tv_sec*1000 + tv.tv_usec/1000;
135 }

2009년 11월 13일 금요일

학점 계산하기 (엑셀용)

쉽고 간단하게 만들어져 있네요 ㅎㅎ

3136 static void task_running_tick(struct rq *rq, struct task_struct *p)

/* time_slice가 0이되면  iterative 와

expired배열의 굶주린 정도를 따져서 알맞은 배열에 삽입한다

*/

3166     if (!--p->time_slice) {
3167         dequeue_task(p, rq->active);
3168         set_tsk_need_resched(p);
3169         p->prio = effective_prio(p);
3170         p->time_slice = task_timeslice(p);
3171         p->first_time_slice = 0;
3172
3173         if (!rq->expired_timestamp)
3174             rq->expired_timestamp = jiffies;
3175         if (!TASK_INTERACTIVE(p) || expired_starving(rq)) {
3176             enqueue_task(p, rq->expired);
3177             if (p->static_prio < rq->best_expired_prio)
3178                 rq->best_expired_prio = p->static_prio;
3179         } else
3180             enqueue_task(p, rq->active);
3181     } else {
3182         /*
3183          * Prevent a too long timeslice allowing a task to monopolize
3184          * the CPU. We do this by splitting up the timeslice into
3185          * smaller pieces.
3186          *
3187          * Note: this does not mean the task's timeslices expire or
3188          * get lost in any way, they just might be preempted by
3189          * another task of equal priority. (one with higher
3190          * priority would have preempted this task already.) We
3191          * requeue this task to the end of the list on this priority
3192          * level, which is in essence a round-robin of tasks with
3193          * equal priority.
3194          *
3195          * This only applies to tasks in the interactive
3196          * delta range with at least TIMESLICE_GRANULARITY to requeue.
3197          */
3198         if (TASK_INTERACTIVE(p) && !((task_timeslice(p) -
3199             p->time_slice) % TIMESLICE_GRANULARITY(p)) &&
3200             (p->time_slice >= TIMESLICE_GRANULARITY(p)) &&
3201             (p->array == rq->active)) {
3202
3203             requeue_task(p, rq->active);
3204             set_tsk_need_resched(p);
3205         }

schedule() 함수

sched.c

 

3413 /*
3414  * schedule() is the main scheduler function.
3415  */
3416 asmlinkage void __sched schedule(void)

 

3474     spin_lock_irq(&rq->lock); // 프로세스 전환시 락을 건다.

spin_lock_irq는 include/linux/spinlock.h 에서 다음과 같이 선언 되어 있다.

210 #define spin_lock_irq(lock)     _spin_lock_irq(lock)

_spin_lock_irq는 kernel/spinlock.c 에 다음과 같이

100 void __lockfunc _spin_lock_irq(spinlock_t *lock)
101 {
102     local_irq_disable();
103     preempt_disable();
104     spin_acquire(&lock->dep_map, 0, 0, _RET_IP_);
105     _raw_spin_lock(lock);
106 }


           array = rq->active;
3501     if (unlikely(!array->nr_active)) {
3502         /*
3503          * Switch the active and expired arrays.
3504          */
3505         schedstat_inc(rq, sched_switch);
3506         rq->active = rq->expired;
3507         rq->expired = array;
3508         array = rq->active;
3509         rq->expired_timestamp = 0;
3510         rq->best_expired_prio = MAX_PRIO;
3511     }
3512
3513     idx = sched_find_first_bit(array->bitmap);//active에서 가장 작은 수로 masking bit를 찾는다.
3514     queue = array->queue + idx;
3515     next = list_entry(queue->next, struct task_struct, run_list);

 

3448     rq = this_rq();  // 현재 rq의 포인터를 가져오는 매크로 함수? 아래와 같이 정의 되어있다.
 293 #define this_rq()       (&__get_cpu_var(runqueues)) 

asm-generic/percpu.h

20 #define __get_cpu_var(var) per_cpu(var, smp_processor_id())

 

3552     sched_info_switch(prev, next);
3553     if (likely(prev != next)) {
3554         next->timestamp = next->last_ran = now;
3555         rq->nr_switches++;
3556         rq->curr = next;
3557         ++*switch_count;
3558
3559         prepare_task_switch(rq, next);
3560         prev = context_switch(rq, prev, next); // <------
3561         barrier();
3562         /*
3563          * this_rq must be evaluated again because prev may have moved
3564          * CPUs since it called schedule(), thus the 'rq' on its stack
3565          * frame will be invalid.
3566          */
3567         finish_task_switch(this_rq(), prev);
3568     } else
3569         spin_unlock_irq(&rq->lock);


 

sturct prio_array

커널 버전 : 2.6.20.18

 

 188 /*
 189  * These are the runqueue data structures:
 190  */
 191
 192 struct prio_array {
 193     unsigned int nr_active;
 194     DECLARE_BITMAP(bitmap, MAX_PRIO+1); /* include 1 bit for delimiter */
 195     struct list_head queue[MAX_PRIO]; 
 196 };

 

sched.h 에서 보면 다음과 같이 선언 되어 있다.

 523 #define MAX_USER_RT_PRIO    100
 524 #define MAX_RT_PRIO     MAX_USER_RT_PRIO
 525
 526 #define MAX_PRIO        (MAX_RT_PRIO + 40)

sched.h(struct runqueue)

커널 버전  2.6.20.18  에서 sched.h

 205 struct rq {
 206     spinlock_t lock; // 프로세서전환시에 락을 걸기위해서 사용
 207
 208     /*
 209      * nr_running and cpu_load should be in the same cacheline because
 210      * remote CPUs use both these fields when doing load calculation.
 211      */
 212     unsigned long nr_running;
 213     unsigned long raw_weighted_load;
 214 #ifdef CONFIG_SMP
 215     unsigned long cpu_load[3];
 216 #endif
 217     unsigned long long nr_switches;
 218
 219     /*
 220      * This is part of a global counter where only the total sum
 221      * over all CPUs matters. A task can increase this counter on
 222      * one CPU and if it got migrated afterwards it may decrease
 223      * it on another CPU. Always updated under the runqueue lock:
 224      */
 225     unsigned long nr_uninterruptible;
 226
 227     unsigned long expired_timestamp;
 228     /* Cached timestamp set by update_cpu_clock() */
 229     unsigned long long most_recent_timestamp;
 230     struct task_struct *curr, *idle;
 231     unsigned long next_balance;
 232     struct mm_struct *prev_mm;
 233     struct prio_array *active, *expired, arrays[2];
 234     int best_expired_prio;
 235     atomic_t nr_iowait;
 236
 237 #ifdef CONFIG_SMP
 238     struct sched_domain *sd;
 239
 240     /* For active balancing */
 241     int active_balance;
 242     int push_cpu;
 243     int cpu;        /* cpu of this runqueue */
 244
 245     struct task_struct *migration_thread;
 246     struct list_head migration_queue;
 247 #endif
 248
 249 #ifdef CONFIG_SCHEDSTATS
 250     /* latency stats */
 251     struct sched_info rq_sched_info;
 252
 253     /* sys_sched_yield() stats */
 254     unsigned long yld_exp_empty;
 255     unsigned long yld_act_empty;
 256     unsigned long yld_both_empty;
 257     unsigned long yld_cnt;
 258
 259     /* schedule() stats */
 260     unsigned long sched_switch;
 261     unsigned long sched_cnt;
 262     unsigned long sched_goidle;
 263
 264     /* try_to_wake_up() stats */
 265     unsigned long ttwu_cnt;

 266     unsigned long ttwu_local;
 267 #endif
 268     struct lock_class_key rq_lock_key;
 269 };

                    

Google blog open!

순간 한글이 안써졌다. ㅡㅡ;

 

vmware-tools을 인스톨하고 있다. 

 

새롭게 리눅스를 깔고 커널을 컴파일 했기 때문이다.

 

OS 프로젝트를 하기 위함이다.ㅎ .. 잘할수 있으려나...

이번 거는 좀 어려울거 같다..    스케줄러를 직접 만들라고 하니 에휴

 

ㅇ ㅏ 낼은

자소서를 써야 할거 같다

 

삼성 인턴에 지원하기 위해서 이다.   시간 나면 사트책이나 좀 빌려 봐야 겠다 ㅎㅎ

vi 환경 설정

$cd  (자신의 홈 디렉토리로 이동한다.)

$vi .vimrc

 

set nu
set tabstop=4           " Tab 크기를 4로 설정
syntax on
set autoindent
set cindent
set smartindent
set ruler " To show Ruler
set mousehide "When typing mouse hide
set hlsearch "When Seach, Result on highlight

set shiftwidth=4        " 자동들여쓰기 크기를 4로 설정
set history=999         " 이전 작업하던 라인을 기억한다.

 

vi를 시작 할때마다 위의 명령어가 실행되도록 자동으로 매트로를 걸어 주는 것임

sched.h

 커널 버전 2.6.30.5 이라서 다른 부분이 많다.

 

kernel/sched.c  

 

  569 struct rq {
  570     /* runqueue lock: */
  571     spinlock_t lock;
  572
  573     /*
  574      * nr_running and cpu_load should be in the same cacheline because
  575      * remote CPUs use both these fields when doing load calculation.
  576      */
  577     unsigned long nr_running;
  578     #define CPU_LOAD_IDX_MAX 5
  579     unsigned long cpu_load[CPU_LOAD_IDX_MAX];
  580 #ifdef CONFIG_NO_HZ
  581     unsigned long last_tick_seen;
  582     unsigned char in_nohz_recently;
  583 #endif
  584     /* capture load from *all* tasks on this cpu: */
  585     struct load_weight load;
  586     unsigned long nr_load_updates;
  587     u64 nr_switches;
  588
  589     struct cfs_rq cfs;
  590     struct rt_rq rt;
  591
  592 #ifdef CONFIG_FAIR_GROUP_SCHED
  593     /* list of leaf cfs_rq on this cpu: */
  594     struct list_head leaf_cfs_rq_list;
  595 #endif
  596 #ifdef CONFIG_RT_GROUP_SCHED
  597     struct list_head leaf_rt_rq_list;
  598 #endif
  599
  600     /*

  601      * This is part of a global counter where only the total sum
  602      * over all CPUs matters. A task can increase this counter on
  603      * one CPU and if it got migrated afterwards it may decrease
  604      * it on another CPU. Always updated under the runqueue lock:
  605      */
  606     unsigned long nr_uninterruptible;
  607
  608     struct task_struct *curr, *idle;
  609     unsigned long next_balance;
  610     struct mm_struct *prev_mm;
  611
  612     u64 clock;
  613
  614     atomic_t nr_iowait;
  615
  616 #ifdef CONFIG_SMP
  617     struct root_domain *rd;
  618     struct sched_domain *sd;
  619
  620     unsigned char idle_at_tick;
  621     /* For active balancing */
  622     int active_balance;
  623     int push_cpu;
  624     /* cpu of this runqueue: */
  625     int cpu;
  626     int online;
  627
  628     unsigned long avg_load_per_task;
  629
  630     struct task_struct *migration_thread;
  631     struct list_head migration_queue;
  632 #endif

  633
  634 #ifdef CONFIG_SCHED_HRTICK
  635 #ifdef CONFIG_SMP
  636     int hrtick_csd_pending;
  637     struct call_single_data hrtick_csd;
  638 #endif
  639     struct hrtimer hrtick_timer;
  640 #endif
  641
  642 #ifdef CONFIG_SCHEDSTATS
  643     /* latency stats */
  644     struct sched_info rq_sched_info;
  645     unsigned long long rq_cpu_time;
  646     /* could above be rq->cfs_rq.exec_clock + rq->rt_rq.rt_runtime ? */
  647
  648     /* sys_sched_yield() stats */
  649     unsigned int yld_count;
  650
  651     /* schedule() stats */
  652     unsigned int sched_switch;
  653     unsigned int sched_count;
  654     unsigned int sched_goidle;
  655
  656     /* try_to_wake_up() stats */
  657     unsigned int ttwu_count;
  658     unsigned int ttwu_local;
  659
  660     /* BKL stats */
  661     unsigned int bkl_count;
  662 #endif
  663 };

네이트온 글씨체

냐 옹 체 !

 

커널 레벨에서 동적 할당

 

kmalloc() , kfree()

 

int *a;

a = (int*)kmalloc(sizeof(int)*4,  option);

 

option 에는

GFP_USER – 커널 영역에 메모리를 할당합니다.  유저 영역에 메모리를 할당하는 것이 아니라 우선순위가 낮을 뿐입니다. May sleep

GFP_KERNEL – 커널 영역에 메모리를 할당하는 가장 신뢰할 수 있는 방법입니다. May sleep GFP_ATOMIC – Interrupt handlers에서 사용됩니다. Not sleep

 

 

kfree(a);

 

2009년 11월 12일 목요일

tar 로 디렉토리 압축

$ ls

1    2

$ tar cvf a.tar.gz 1 2

$ ls

1   2  a.tar.gz

 

압출을 풀때는 옵션에 xvf


압축이라기 보다는 파일 묶기라는  표현이 정확!