리눅스2013. 11. 24. 16:51


출처:http://docs.fedoraproject.org/en-US/Fedora/14/html/Storage_Administration_Guide/writebarr.html

Chapter 16. Write Barriers

write barrier is a kernel mechanism used to ensure that file system metadata is correctly written and ordered on persistent storage, even when storage devices with volatile write caches lose power. File systems with write barriers enabled also ensure that data transmitted via fsync() is persistent throughout a power loss.
Enabling write barriers incurs a substantial performance penalty for some applications. Specifically, applications that use fsync() heavily or create and delete many small files will likely run much slower.

16.1. Importance of Write Barriers

File systems take great care to safely update metadata, ensuring consistency. Journalled file systems bundle metadata updates into transactions and send them to persistent storage in the following manner:
  1. First, the file system sends the body of the transaction to the storage device.
  2. Then, the file system sends a commit block.
  3. If the transaction and its corresponding commit block are written to disk, the file system assumes that the transaction will survive any power failure.
However, file system integrity during power failure becomes more complex for storage devices with extra caches. Storage target devices like local S-ATA or SAS drives may have write caches ranging from 32MB to 64MB in size (with modern drives). Hardware RAID controllers often contain internal write caches. Further, high end arrays, like those from NetApp, IBM, Hitachi and EMC (among others), also have large caches.
Storage devices with write caches report I/O as "complete" when the data is in cache; if the cache loses power, it loses its data as well. Worse, as the cache de-stages to persistent storage, it may change the original metadata ordering. When this occurs, the commit block may be present on disk without having the complete, associated transaction in place. As a result, the journal may replay these uninitialized transaction blocks into the file system during post-power-loss recovery; this will cause data inconsistency and corruption.

How Write Barriers Work

Write barriers are implemented in the Linux kernel via storage write cache flushes before and after the I/O, which isorder-critical. After the transaction is written, the storage cache is flushed, the commit block is written, and the cache is flushed again. This ensures that:
  • The disk contains all the data.
  • No re-ordering has occurred.
With barriers enabled, an fsync() call will also issue a storage cache flush. This guarantees that file data is persistent on disk even if power loss occurs shortly after fsync() returns.


'리눅스' 카테고리의 다른 글

sysroot  (0) 2014.03.14
[EXT4] noauto_da_alloc 옵션에 대해서  (0) 2013.11.25
[Mint Linux] gnome shell emulation  (0) 2012.09.08
우분투 remote 로 접속해서 X 서버 돌리기  (0) 2012.04.17
ext4분석  (0) 2012.04.10
Posted by code cat
프로그래밍/C2013. 11. 24. 00:11

자 아래를 보자

void DLL_PrintNodes(Node* head){

 Node* current;
 current = head;
 int idx = 0;

 while(current->NextNode != NULL) {
  printf("[%d] %d\n", idx++, current->Data);
  current = current->NextNode;
 }
}

 

문제가 보이는가? 실행하면...

 error C2143: 구문 오류 : ';'이(가) '형식' 앞에 없습니다.
 error C2065: 'idx' : 선언되지 않은 식별자입니다.

 

응???

linux에서 gcc 툴체인으로 작업하는 사람들은 위와 같은 반응을 보일텐데...

 

MSDN에서는 다음과 같이 말하고 있다.  C에서는 함수나 블록의 시작점에 지역변수들은 선언되야 하며, 함수가 선언이 아닌 명령어들을 실행하고 나서는 선언이 들어 올 수 없다고...

 

예) 

// C2143j.c
int main() 
{
    int i = 0;
    i++;
    int j = 0; // C2143 에러
}

 

그럼 왜 GCC에서는 괜찮은가? 그건 GCC가 위와 같은 코드를 GNU확장으로 허용하기 때문이다.  만약 ANSI나 C89등에 맞추어서 컴파일 되길 원한다면, -pedantic을 flag로 넘겨주면 된다.

'프로그래밍 > C' 카테고리의 다른 글

함수포인터 & typdef를 이용한 함수포인터  (0) 2014.05.07
ternary operator  (0) 2014.04.13
c precedence table  (0) 2013.11.23
typedef struct 안에서 스스로를 참조 할 때 주의점  (0) 2013.11.19
symbol visibility  (0) 2013.08.07
Posted by code cat
프로그래밍/C2013. 11. 23. 23:29

Level Symbol Description Associativity
1 ++
--
( )
[ ]
->
.
Prefix increment
Prefix decrement
Function call and subexpression
Array subscript
Structure pointer
Structure member
left to right
2 !
~
-
+
(type)
*
&
sizeof
Logical negation
1's complement
Unary negation
Unary plus
Type cast
Pointer dereference
Address of
Size of
right to left
3 *
/
%
Multiplication
Division
Modulus (integer remainder)
left to right
4 +
-
Addition
Subtraction
left to right
5 <<
>>
Bitwise left shift
Bitwise right shift
left to right
6 <
<=
>
>=
Less than
Less than or equal to
Greater than
Greater than or equal to
left to right
7 ==
!=
Equal test
Not equal test
left to right
8 & Bitwise AND left to right
9 ^ Bitwise exclusive OR (XOR) left to right
10 | Bitwise inclusive OR left to right
11 && Logical AND left to right
12 || Logical inclusive OR left to right
13 ?: Conditional test right to left
14 =
+=
-=
*=
/=
%=
<<=
>>=
&=
^=
|
Assignment
Compound add
Compound subtract
Compound multiply
Compound divide
Compound modulus
Compound bitwise left shift
Compound bitwise right shift
Compound bise AND
Compound bitwise exclusive OR
Compound bitwise inclusive OR
right to left
15 ,
++
--
Sequence point (list separator)
Postfix increment
Postfix decrement
left to right

Posted by code cat
프로그래밍/JAVA2013. 11. 19. 23:57

참고사이트: http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html#available


SystemLookAndFeel 종류

PlatformLook and Feel
Solaris, Linux with GTK+ 2.2 or laterGTK+
Other Solaris, LinuxMotif
IBM UNIXIBM*
HP UXHP*
Classic WindowsWindows
Windows XPWindows XP
Windows VistaWindows Vista
MacintoshMacintosh*


LookAndFeel 세팅 방법은 다음과 같다.

public static void main(String[] args) {
    try {
            // Set System L&F
        UIManager.setLookAndFeel(
            UIManager.getSystemLookAndFeelClassName());

//UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel"); //직접 타이핑해서 넣어도 된다.

} catch (UnsupportedLookAndFeelException e) { // handle exception } catch (ClassNotFoundException e) { // handle exception } catch (InstantiationException e) { // handle exception } catch (IllegalAccessException e) { // handle exception } new SwingApplication(); //Create and show the GUI. }


'프로그래밍 > JAVA' 카테고리의 다른 글

OTA Package Utility  (0) 2013.11.25
Java Generics  (0) 2012.10.01
WindowBuilder Pro for Eclipse 3.7(Indigo) 설치 오류  (0) 2012.08.06
ant 빌드가 안될 때  (0) 2011.10.19
Posted by code cat
프로그래밍/C2013. 11. 19. 22:57

typedef struct g_struct {

  int value;

  struct g_struct *next;  //OK

  //gStruct *next  //WRONG!

} gStruct;



알겠지만, 적어도 C에서는 typedef struct 정의 안에서 typedef 된 개체 자체를 reference할 수 없다. 

'프로그래밍 > C' 카테고리의 다른 글

[visual studio] 에러 C2143 로컬변수 선언 위치  (0) 2013.11.24
c precedence table  (0) 2013.11.23
symbol visibility  (0) 2013.08.07
typedef 와 static 을 동시에 사용 못하는 이유  (0) 2012.11.24
인라인 어셈블리  (0) 2012.09.25
Posted by code cat