2016년 2월 17일 수요일

Level Trigger VS Edge Tigger



  • Picture Compare






  • Level Trigger

- as using Level Trigger Method, Event is continually generated while input buffer is remaining extra space.

- I give 'BUF_SIZE' 5 size in order to compare Level Trigger to Edge Trigger.

ex) Level Trigger execution screen

- Also 'select' is a Level Trigger. => received data existance check

  • Edge Trigger

ex) This Test transform 'EPOLLIN' into 'EPOLLIN | EPOLLET'.


- Edge Trigger Mothod can generate one event.
  however, Server doesn't completely receive data which Client send.
     epoll_wait() call -> fetch 5byte -> event generation wait...


◈ Use 'fcntl' to use Non-blocking I/O
- int flag=fcntl(fd, F_GETFL, 0);    => fetch existing option information
- fcntl(fd, F_SETFL, flag|O_NONBLOCK);   => existing option add new attribute.

Why do Non-blocking mode use?
Answer:  As Edge Trigger characteristic, read & write Function Call stop executing Server for a long time.

◈ Use 'errno' which is extern valuable in the other file.
- 'errno' valuable value is different in functions whenever Error generated.

else if(str_len<0) // (1)
{
if(errno==EAGAIN) // (2)
break;
}

(1) What return value of read() have -1 is two meaning.
     Buffer is empty or Error generated
(2) EAGAIN mean that Buffer is empty because data don't exist in the buffer.


  • Echo Server & Client using Edge Trigger related to 'epoll' 





Source Code

댓글 없음:

댓글 쓰기