어플에서 사용되는 printf()  함수의 경우 호출된 시점 이후에 언제 출력이 될지 알지 못한다.

printf()  함수는 그져 버퍼에 쌓기만 하고 인터럽트에 의해 출력되기 때문이다.


그렇다면 리눅스 커널에서 사용되는 printk() 함수는 어떨까?

이를 위해 다음과 같은 기능을 하는 드라이버를 작성하였다.


  gpio 출력  High

    printk( '"메세지 개수 가변" )

  gpio 출력  Low


위와 같이 하여 출력메세지의 개수에 따라 GPIO 신호의 파형이 어떻게 움직이는지 확인하였다.

EM-S5PV210 모듈과 SIB-G100  IO보드를 사용하여 테스트 하였다.


결과>

메세지의 개수가 많을 수록 GPIO 의 High 상태가 길게 유지되었다.

어찌보면 당연한 결과이다. 하지만 추정했던 내용을 정확히 알게 되니 속시원하다.


아래는 테스트 소스이다.


/**    
    @file     test-printk.c
    @date     2011/10/14
    @author   오재경 freefrug@falinux.com  FALinux.Co.,Ltd.
    @brief    printk 가 인터럽트를 사용하지 않고 출력하는지 
              혹은 메세지 버퍼를 사용하여 출력하는지 GPIO 를 사용하여 실험해본다.
    @todo     
    @bug     
    @remark  
    		컴파일방법@pc> CROSS_COMPILE=arm-generic-linux-gnueabi- ARCH=arm make
    
    @warning 
*/
//----------------------------------------------------------------------------

#define __MODULES__
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/sched.h> 
#include <linux/interrupt.h>
#include <linux/wait.h>
#include <linux/ioport.h>
#include <linux/slab.h> 
#include <linux/poll.h>     
#include <linux/proc_fs.h>
#include <linux/workqueue.h>
#include <linux/time.h>			
#include <linux/timer.h>		
#include <asm/system.h>     
#include <asm/uaccess.h>
#include <asm/ioctl.h>
#include <asm/unistd.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/delay.h>
#include <linux/gpio.h>
#include <mach/regs-gpio.h>
static int msgcnt = 32;
static int test_init( void )
{
	char buf[4096];
	memset( buf, 'A', sizeof(buf) );
	buf[msgcnt] = 0;
	// GPH0_6 (EINT6)
 	gpio_direction_output( S5PV210_GPH0(6), 0 );		
 	
	gpio_set_value( S5PV210_GPH0(6), 1 );
	printk( "%s\n", buf );  
	gpio_set_value( S5PV210_GPH0(6), 0 );
	udelay( 1000 );
	return 0;
}
static __exit void test_exit( void )
{
	//
}
module_init(test_init);
module_exit(test_exit);
module_param(msgcnt, int, 0);
MODULE_AUTHOR("freefrug@falinux.com");
MODULE_LICENSE("GPL");
/* end */