리눅스/커널2013. 1. 13. 14:41

priority inversion :

현상:

높은 우선 순위의 태스크가 접근하려고 하는 공유자원을 낮은 우선 순의의 태스크가  이미 사용하고 있을 때, 중간 우선 순위에 해당하는 태스크가 수행되어 상위 우선 태스크를 수행하지 못하게 되는 현상


해결 방법:

낮은 우선 순위의 태스크의 우선 순위를 높은 우선 순위로 올려서 높은 우선 순위로 수행되게 하고 공유 자원을 시스템에 반환하도록 하면 그 후 높은 우선 순위의 태스크가 수행되게 된다.


뮤텍스관련 해결 방법

priority inheritance protocol: 뮤텍스를 획득한 낮은 우선 순위 태스크의 우선 순위를 임시로 뮤텍스를 요청한 높은 우선 순위 태스크의 우선 순위 값과 같게 오려준다.  변경된 태스크의 우선 순위는 뮤텍스 반환 동시에 본래의 값으로 돌아간다.

ceiling priority protocol: 태스크가 뮤텍스를 획득할 때 태스크의 우선 순위를 해당 뮤텍스를 사용할 가능성이 있는 태스크 중 가장 높은 우선 순위를 가진 태스크의 우선 순위로 변경한다.  뮤텍스가 반환될 때 태스크의 우선 순위는 본래 값으로 돌아간다.


'리눅스 > 커널' 카테고리의 다른 글

[안드로이드][커널]Unknown symbol _GLOBAL_OFFSET_TABLE_  (0) 2013.08.09
Kernel Oops의 Taint 종류  (0) 2013.07.25
monolithic vs microkernel  (0) 2013.01.13
VFS(1) -구조체-  (0) 2012.12.08
VFS(1) -추상적 레이어-  (0) 2012.12.08
Posted by code cat
리눅스/커널2013. 1. 13. 12:58

출처:  http://en.wikipedia.org/wiki/File:OS-structure2.svg



'리눅스 > 커널' 카테고리의 다른 글

Kernel Oops의 Taint 종류  (0) 2013.07.25
[OS] priority inversion 해결방법  (0) 2013.01.13
VFS(1) -구조체-  (0) 2012.12.08
VFS(1) -추상적 레이어-  (0) 2012.12.08
make menuconfig 시에 원하는 옵션 찾아보기  (0) 2012.11.30
Posted by code cat
리눅스/커널2012. 12. 8. 11:28

VFS는 다음과 같은 구조체들이 있다.

  • 특정 파일 시스템을 표현하는 superblock 구조체
  • 특정 파일을 표현하는 inode 구조체
  • 특정 디렉터리와 경로를 표현하는 dentry 구조체
  • 프로세스와 관련해 열린 파일 구조체

눈여겨 보아야 할 점은 리눅스커널에서는 디렉터리 자체도 파일로 취급을 한다.

또한 위의 객체 따른 여러가지 operation 구조체들이 있는데 다음과 같다.

  • super_operations
  • inode_operations
  • dentry_operations
  • file operation

이들 operation 구조체들은 각 VFS구조들에 대해 함수 포인터의 구조체로 구현되어 있다.

그 밖에 구조체들에는

  • registered 된 파일 시스템을 표현하는 file_syste_type 구조체
  • 마운트 포인트를 알리는 vfsmount 구조체
  • 프로세스와 관련해 열린 파일을 표현하는 file_struct, fs_struct, namespace 구조체

'리눅스 > 커널' 카테고리의 다른 글

[OS] priority inversion 해결방법  (0) 2013.01.13
monolithic vs microkernel  (0) 2013.01.13
VFS(1) -추상적 레이어-  (0) 2012.12.08
make menuconfig 시에 원하는 옵션 찾아보기  (0) 2012.11.30
initarray_cache vs arraycache_init  (0) 2012.10.21
Posted by code cat
리눅스/커널2012. 12. 8. 10:46

리눅스 커널은 많은 서브 시스템에 Virtaul Fiel System(이하 VFS) 이라는 파일 시스템 인터페이스를 유저공간 프로그램에 제공한다.

 

VFS는 open(), read(), write(), close()같은 시스템콜들이 특정 파일 시스템에 의존하지 않도록 설계되었는데, 이는 커널의 low-level 파일 시스템 interface에서 범용 인터페이스 방식으로  제공하기에 가능하다.  이 범용 인터페이스 방식은 일종의 추상적 개념이라고 할 수 있다.  즉 VFS는 최소단의 기본 동작에 대해서 추상적 인터페이스와 그에 필요한 자료 구조를 정의하고, 세부 구현등에 대해서는 파일 시스템에 알아서 맞추라고 한다.

쉽게 말해, VFS는 갑이고, 파일 시스템은 을이다.

 

VFS(갑) : 이게 이번에 우리가 필요한 사항이고요, 단가 알아서 맞추시고요.

파일시스템(을): 이런 ㅆ.. 네.

 

웃자고 한 거고, 사실은 저렇게 추상적인 개념을 제공함으로써 유저공간 프로그램들은 어떤 파일시스템이 어떻게, 예를 들어 read() 를 구현했는지 어떻게 동작했는지 상관안하고, read를 호출할 수 있는 것이다.

'리눅스 > 커널' 카테고리의 다른 글

monolithic vs microkernel  (0) 2013.01.13
VFS(1) -구조체-  (0) 2012.12.08
make menuconfig 시에 원하는 옵션 찾아보기  (0) 2012.11.30
initarray_cache vs arraycache_init  (0) 2012.10.21
BYTES_PER_WORD  (0) 2012.10.15
Posted by code cat
리눅스/커널2012. 11. 30. 19:45

커널에서 make menuconfig으로 컴파일 설정 시에 원하는 옵션이 어디에 있는지 모르겠다면, /를 누르면 CONFIG_로 search 할 수 있게 된다.

 

몰랐는데, 아니까 너무 편하다!!!!

'리눅스 > 커널' 카테고리의 다른 글

VFS(1) -구조체-  (0) 2012.12.08
VFS(1) -추상적 레이어-  (0) 2012.12.08
initarray_cache vs arraycache_init  (0) 2012.10.21
BYTES_PER_WORD  (0) 2012.10.15
Newton-Raphson technique  (0) 2012.10.15
Posted by code cat

Using GNU Make's 'define' and '$(eval)' to automate rule creation

About once a week I get an email from someone random asking a question about GNU Make. I do my best to answer and figured it might be helpful for others if I shared these questions and my answers. So, here goes. This one starts with a Princess Leia style appeal:
I stumbled across your name when googling for help on a GNUmake related problem, hope you have the time to look at it as you are my last hope. I have the following problem in my Makefile:
$(LIBDIR)/libfoo.a: $(filter $(OBJDIR)/foo/%,$(OBJECTS)) 
$(LIBDIR)/libbar.a: $(filter $(OBJDIR)/bar/%,$(OBJECTS)) 
$(LIBDIR)/libbaz.a: $(filter $(OBJDIR)/baz/%,$(OBJECTS)) 
  
$(LIBDIR)/%.a: 
        ar -r $@ $^ 
        ranlib $@
so far, so good - it works as expected. The only problem is, that in the real world it's not just foo, bar and baz for me and I hate having to maintain the list manually. What I would like to do is something like this:
$(LIBDIR)/lib%.a: $(filter $(OBJDIR)/%/%,$(OBJECTS)) 
        ar -r $@ $^ 
        ranlib $@
but now the pattern for filter has two percentage-characters and this seem to confuse GNUmake. I tried to escape it, use $(call …), etc. but nothing really works. Do you have any trick/hint/idea how to solve this??

Thanks for your time, Best Regards,
And my reply:
Thanks for your mail. I can see what you are trying to do. I think the easiest way out of your predicament is as follows:
# Example of manually maintained list 
# 
# $(LIBDIR)/libfoo.a: $(filter $(OBJDIR)/foo/%,$(OBJECTS)) 
# $(LIBDIR)/libbar.a: $(filter $(OBJDIR)/bar/%,$(OBJECTS)) 
# $(LIBDIR)/libbaz.a: $(filter $(OBJDIR)/baz/%,$(OBJECTS)) 
# 
# $(LIBDIR)/%.a: 
#        ar -r $@ $^ 
#        ranlib $@ 
 
# What you'd like to be able to do 
# 
# $(LIBDIR)/lib%.a: $(filter $(OBJDIR)/%/%,$(OBJECTS)) 
#        ar -r $@ $^ 
#        ranlib $@ 
 
# The following will work 
# 
# Suppose, for example: 
 
LIBDIR  := lib 
OBJDIR  := obj 
OBJECTS := $(OBJDIR)/foo/hello.o $(OBJDIR)/foo/bar.o $(OBJDIR)/bar/hello.o \ 
$(OBJDIR)/baz/bar.o 
 
# Extract the names of the first level directories underneath 
# $(OBJDIR) and make a unique list (sort removes duplicates) and store 
# that in LIBNAMES.  This assumes that there are no spaces in any of 
# the filenames in $(OBJECTS) and that each element of $(OBJECTS) 
# starts with $(OBJDIR) 
 
LIBNAMES := $(sort $(foreach a,$(patsubst $(OBJDIR)/%,%,$(OBJECTS)),\ 
$(firstword $(subst /, ,$a)))) 
 
# The following function finds all the objects in $(OBJECTS) in a 
# particular directory whose name can be found in LIBNAMES.  So, in 
# the example here doing $(call find-objects,foo) would return 
# obj/foo/hello.o obj/foo/bar.o 
 
find-objects = $(filter $(OBJDIR)/$1/%,$(OBJECTS)) 
 
# Now need to define the rule that handles each of the libraries 
# mentioned in $(LIBNAMES).  This function can be used with $(eval) to 
# define the rule for a single directory 
 
define make-library  
$(LIBDIR)/lib$1.a: $(call find-objects,$1) 
        ar -r $$@ $$^ 
        ranlib $$@ 
endef 
 
# Now define the rules for all the directories found in $(LIBNAMES) 
 
$(foreach d,$(LIBNAMES),$(eval $(call make-library,$d)))
You will need a version of GNU Make that supports $(eval).

 

Posted by code cat

만일 빼고 싶은 패스가 /home/user/bin이라면, 다음과 같이 하면 된다.

PATH=$(echo $PATH | sed -e 's;:\?/home/user/bin;;' -e 's;/home/user/bin:\?;;')
Posted by code cat
리눅스/커널2012. 10. 21. 23:51

slab allocation에서 나오는 두개가 헷갈렸었는데, 찾아보니 별거 아니였다.


initarray_cache는


arraycache_init는


결국, initarray_cache는 arraycache_init 타입으로 정적으로 만들어져 initdata 영역에 미리 준비되는(cache_cache 생성시 필요) 것이었다.

'리눅스 > 커널' 카테고리의 다른 글

VFS(1) -추상적 레이어-  (0) 2012.12.08
make menuconfig 시에 원하는 옵션 찾아보기  (0) 2012.11.30
BYTES_PER_WORD  (0) 2012.10.15
Newton-Raphson technique  (0) 2012.10.15
linux kernel, mem_init()  (0) 2012.10.05
Posted by code cat

출처: AOSP

소문자 a랑 대문자 B를 text파일(대소문자구별)에 넣고, 소문자로만 된 text파일을 다시 읽어서 무슨 글자가 있나 확인하는 로직이다.  간단하면서 잘 동작한다.

Posted by code cat

Makefile에서 가끔 파일의 존재 여부를 보고 선행 작업을 해줘야 할 때가 있다. 그럴 때는 다음의 간단한 예제를 보고 응용하자.

  (예제를 위한 거니 밑에처럼 하지는 말자...)


Posted by code cat