'Education'에 해당되는 글 58건

  1. 2009.09.07 Fedora11 ( linux-2.6.29.4 ) Compile 과정 by 초상큼발랄
  2. 2009.09.07 root 계정 by 초상큼발랄
  3. 2009.09.04 Signal 과 Slot 예제 by 초상큼발랄
  4. 2009.09.04 QT designer 4 by 초상큼발랄
  5. 2009.09.04 운영체제 개요 by 초상큼발랄
  6. 2009.08.27 TCP by 초상큼발랄 1
  7. 2009.08.27 UDP by 초상큼발랄
  8. 2009.08.26 Module by 초상큼발랄

1. 커널 다운
2. 압축 풀기

# tar xvfz linux-2.6.29.4.tar.gz


3. 압축 푼 커널 이동

# mv linux-2.6.29.4 /usr/src

4. 압축 해제된 디렉토리로 이동

#  cd /usr/src/linux-2.6.29.4
 
5. 이전 오브젝트 파일 삭제 
 
# make mrproper

6. 환경 설정

# make menuconfig 

7. 컴파일
- /usr/src/linux-2.6.29.4/arch/i686/boot 디렉토리에 bzImage를 생성하는 커널 컴파일 과정 수행
-  make dep, clean, bzImage 명령을 make 명령어로 한번에 처리

# make
 
8. 모듈 설정
- make menuconfig 환경설정에서 (M)로 선택한 모듈 부분을 커널 내부 구성요소에게 알려주고 그 구성요소들이 사용될 때 Auto kenel 적재가능하게 설정

# make modules
 
9. 모듈 설치
- 8번 단계에서 설정한 대로 설치

#make modules_install

10.
 - 자동으로 /boot 디렉토리에 initrd-2.6.18.img, vmlinux-2.6.18 파일들을 생성하고 이동시킨다.
 - 예전의 2.4.x 커널 컴파일 방식보다 매우 편리하고 간단하게 커널컴파일 과정을 할 수 있다. 또한 /boot/grub/grub.conf 혹은 menu.list 파일을 자동으로 변경해주어 따로 부트로더 설정할 필요가 없어졌다.

#make install

11. 재부팅
# reboot

'Education > Linux Kernel' 카테고리의 다른 글

커널 소스 트리  (0) 2009.11.18
root passwd  (0) 2009.10.28
명령어  (0) 2009.10.28
Samba 설치  (0) 2009.09.24
root 계정  (0) 2009.09.07
Posted by 초상큼발랄
l

root 계정

1. Login in as a regular user

# vi /etc/pam.d/gdm

2. Remove or comment out

# auth required pam_succeed_if.so user != root quiet

3. Save and close

4. In Fedora 11, follow the cource of top

# vi /etc/pam.d/gdm-password

-> Remove or commet out  " # auth required pam_succeed_if.so user != root quiet "

'Education > Linux Kernel' 카테고리의 다른 글

커널 소스 트리  (0) 2009.11.18
root passwd  (0) 2009.10.28
명령어  (0) 2009.10.28
Samba 설치  (0) 2009.09.24
Fedora11 ( linux-2.6.29.4 ) Compile 과정  (0) 2009.09.07
Posted by 초상큼발랄
l

<foo.h>

  #ifndef __FOO_H_
  #define __FOO_H_
  
  #include <QObject>
  
  class Foo : public QObject
  {
      Q_OBJECT
  
      public:
          Foo() {}
          int value() const { return val; }
  
          public slots:
              void setValue(int v)
              {
                  if(v != val)
                  {
                      val = v;
                      emit valueChanged(v);
                  }
              }
  
      signals:
          void valueChanged(int);
  
      private:
          int val;
  };
  
  #endif


<foo.cpp>        

  #include <QApplication>
  #include <iostream>
  
  using namespace std;
  
  #include "foo.h"
  
  int main(int argc, char ** argv)
  {
      QApplication app(argc, argv);
      Foo a,b;
      int ret;
  
      QObject::connect(&a, SIGNAL(valueChanged(int)), &b, SLOT(setValue(int)));
      b.setValue(11);
      a.setValue(79);
      ret = b.value();
  
      cout << ret << endl;
  
      return 0;
  }       



-> 출력 79

'Education > QT programming' 카테고리의 다른 글

madplayer  (4) 2009.11.04
mount  (7) 2009.11.03
QT designer 4  (0) 2009.09.04
Posted by 초상큼발랄
l


# cd /qtwork/

# mkdir Hello_World

# cd Hello_World


# $QTDIR

# source /work/qtx/qtx_env

# designer //Designer 실행

# uic hello_world.ui > ui_hello_world.h

# vi hello_world.h

#ifndef __HELLODLG_H__
#define __HEELLODLG_H__

#include <QDialog>
#include "ui_hello_world.h"

class QPushButton;
class QTextBrowser;

class Hello_World : public QDialog
{
Q_OBJECT

public:
Hello_World();

public slots:
void pb_ok_clicked();

private:
Ui::Hello_World ui;
};

#endif
# vi hello_world.cpp
#include <QPushButton>
#include <QTextBrowser>

#include "hello_world.h"

Hello_World::Hello_World()
{
ui.setupUi(this);
connect(ui.pb_ok, SIGNAL(clicked()), this, SLOT(pb_ok_clicked()));
}

void Hello_World::pb_ok_clicked()
{
printf("test\n");
ui.le_output->insert("Hello_World");
}

# vi main.cpp
#include <QApplication>
#include "hello_world.h"

int main(int argc, char **argv)
{
QApplication app(argc, argv);
Hello_World dlg;
dlg.show();
return app.exec();
}

# qmake -project

# qmake

# make

# ./hello_world

'Education > QT programming' 카테고리의 다른 글

madplayer  (4) 2009.11.04
mount  (7) 2009.11.03
Signal 과 Slot 예제  (0) 2009.09.04
Posted by 초상큼발랄
l
 


- System call iinterface : OS의 기능을 호츨하기 위해 사용되는 구조
사용자 모드를 kernel 모드로 전환 발생
- H/W의 메모리는 사용자에게 보이지 않는다 -> 실제 메모리(physical memory)는 감추고 모든 응용 프로그램이 각각 가상주소 0번지에서 시작하여 연속적인 메모리를 사용하는 것으로 느끼게 하는 것이다. 



* 운영체제: 응용프로그램의 수행을 제어하고 컴퓨터 사용자와 컴퓨터 하드웨어 사이의 interface 역할을 하는 프로그램
#기능
1. 사용자에게 편리한 환경 제공
2. 컴퓨터 시스템 자원이 효율적으로 동작 할 수 있도록 제어
# 요소
Processor
Memory
Main Memory
비휘발성
real memory 또는 primary memory 로 여겨짐 
Virtual Memory
만약에 32bits의 CPU를 사용한다면 실제 접근 가능한 Memory는 2^32 = 4G 만큼 사용 가능
          64bits system이라면 2^64bits memory 사용 가능
물리M 와 가상 M 는 다를 수도 있다. 사용자가 보는 관점에서는 가상 Memory를 본다.

MMU(Memory Management Unit) : 메모리 관리 
MMU table에서 가상 M와 물리 M를 Mapping 시켜준다. -> 가상M의 주소가 어떤 물리M의 주소인지 매치시킴
가상 메모리 주소   물리 메모리 주소
...   ...
   
   
< MMU Table>
Memory 속도가 늦어서 가급적 접근을 줄임 -> 그래서 cache($)라는 고속 메모리를 사용한다.

TLB(Translation Lookaside Buffer) : 변환 Memory의 주소 cache 


I/O Modules
System Bus
# 목적
편리성
효율성
발전성


@ Race condition : 한정된 자원(H/W, Resource)을 차지하려는 경쟁
다중 프로그래밍 시스템 또는 다중 처리기 시스템에서 두 명령어가 동시에 같은 기억 장소를 접근하려고 하는 상황
@ Muti Tasking : 동시에 여러 개의 processor(Application)이 수행하는 환경
@ SMP(Symmetric Multi Processor) : 한 개 이상의 processor가 장착되고 각 processor에 부하를 똑같이 분배 시킬 수 있는
운영체제가 구비된 컴퓨터 시스템
@ Hibration (동면 발생) : 노트북 사용시, 전원이 나가면 메모리의 데이터를 저장한 후, 전원이 나갔다가 다시 충전 후 데이터들을 메모리에 올려 사용 가능

'Education > Operating System' 카테고리의 다른 글

Trace of Process  (2) 2009.10.12
HAL(Hardware Abstraction Layer)  (0) 2009.10.07
프로세스  (0) 2009.10.07
운영체제  (0) 2009.10.06
1. 운영체재 개요  (0) 2009.09.10
Posted by 초상큼발랄
l

TCP

Education/Networking 2009. 8. 27. 18:19


<server.c>

#include <stdio.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

#include <signal.h>

#define SERV_PORT 62000
#define RECV_BUF_LEN 80

void sig_alrm(int signo);

void sig_alrm(int signo)
{

 printf("alarm...\n");

}

void sig_child(int signo)
{

 printf("Client terminated \n");

}


int main(int argc, char *argv[])
{

 int sfd, cfd;
 struct sockaddr_in saddr;
 struct sockaddr_in caddr;
 int size, len;
 char recv_buf[RECV_BUF_LEN];

 pid_t pid;

 sfd = socket(AF_INET, SOCK_STREAM, 0);
 len = sizeof(saddr);

 bzero((char*)&saddr, sizeof(saddr));
 saddr.sin_family = AF_INET;
 saddr.sin_addr.s_addr = htonl(INADDR_ANY);
 saddr.sin_port = htons(SERV_PORT);

 if ( bind(sfd, (struct sockaddr*)&saddr, sizeof(saddr)) < 0 ) {

  printf("Bind Error\n");
  return -1;

 }

 listen(sfd, 5);

 signal(SIGALRM, sig_alrm); 
 signal(SIGCHLD, sig_child); 
 //signal(SIGINT, SIG_IGN); //ignore 
 size = sizeof(caddr);

 while (1)
 {

  cfd = accept(sfd, (struct sockaddr*)&caddr, &size);//connect
  printf("Client : %d\n", cfd);

  pid = fork(); // call pre-fork() function

  if(pid <0)
  {
   printf("Fork Error!!\n");
   exit(-1);

  }

  else if(pid==0) //child process
  {

  // alarm(3);
   while(len = read(cfd, recv_buf, RECV_BUF_LEN))
   {

    recv_buf[len] = '\0';
    printf("recv : %s", recv_buf);
    

    if(strncmp(recv_buf, "exit",4) == 0)//client request termination.
    { 

//     close(cfd);
//     close(sfd);
//     return 0;
     exit(1);

    }         // alarm(0);

  else//parent process
  {
  }

 }

}

}

 close(cfd);
 close(sfd);

 return 0;

}






<client.c>

#include <stdio.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

#define SERV_PORT 62000
#define RECV_BUF_LEN 1024
#define MSG_SIZE 1024

int main(int argc, char *argv[])
{

 int sfd;
 struct sockaddr_in saddr;
 int len, msglen;
 static char msg[MSG_SIZE];

 sfd = socket(AF_INET, SOCK_STREAM, 0);

 bzero((char*)&saddr, sizeof(saddr));
 saddr.sin_family = AF_INET;
 saddr.sin_addr.s_addr = inet_addr(argv[1]);
 saddr.sin_port = htons(SERV_PORT);

 if (connect(sfd, (struct sockaddr*)&saddr, sizeof(saddr)) < 0) {

  printf("connect error\n");
  return -1;

 }

 while (1)
{

  msglen = read(STDIN_FILENO, msg, MSG_SIZE);

  if (len = write(sfd, msg, msglen) < msglen)
{

   printf("write error\n");

  }

  if (strncmp(msg, "exit", 4) == 0)
  {

   close(sfd);
   return 0;

  }

 }

// close(sfd);

 return 0;

}


 

'Education > Networking' 카테고리의 다른 글

UDP  (0) 2009.08.27
Posted by 초상큼발랄
l

UDP

Education/Networking 2009. 8. 27. 18:09


<server_udp.c>

#include <stdio.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

#include <signal.h>


void error(char *msg)
{

 perror(msg);
 exit(0);

}

int main(int argc, char *argv[])
{

 int sock, length, fromlen, n;
 struct sockaddr_in server;
 struct sockaddr_in from;

 char buf[1024];

 if(argc < 2)
 {

  fprintf(stderr, "ERROR, no port provided\n");
  exit(0);

 }

 sock = socket(AF_INET, SOCK_DGRAM, 0);

 if(sock <0) error("Opening socket");

 length = sizeof(server);

 bzero(&server, length);
 server.sin_family = AF_INET;
 server.sin_addr.s_addr  = INADDR_ANY;
 //server.sin_port  = htons(atoi(argv[1]));
 server.sin_port  = htons(8024);
 
 if( bind(sock, (struct sockaddr *)&server, length) < 0 )
  error("Binding");
 fromlen = sizeof(struct sockaddr_in);

 while (1)
 {

  n = recvfrom(sock, buf, 256, 0, (struct sockaddr *)&from, &fromlen);

  if(n <0)
  { 

   error("recvfrom");
   printf("Receive size 0\n");
   exit(-1);

  }
  
  write( 1, "Received a datagram: ", 21);
  buf[n] = '\0';
  write( 1, buf, n);

  n = sendto(sock,"Got your msg\n",13, 0, (struct sockaddr *)&from, sizeof(from));

  if(n <0) error("sendto");

 }

}



<client_udp.c>

#include <stdio.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>

#include <signal.h>

void error(char *);

int main(int argc, char *argv[])
{

 int sock, length, n;
 struct sockaddr_in server, from;
 struct hostent *hp;

 char buffer[256];
 
 if(argc != 3)
 {

  printf("Usage: server port \n");
  exit(1);

 }

 sock = (AF_INET, SOCK_DGRAM, 0);
 if(sock <0) error("Socket\n");

 server.sin_family = AF_INET;
 hp = gethostbyname(argv[1]);
 if(hp==0) error("Unknown host\n");

 bcopy((char *)hp->h_addr, (char *)&server.sin_addr, hp->h_length);
 //server.sin_port = htons(atoi(argv[2]));
 server.sin_port = htons(8024);
 length = sizeof(struct sockaddr_in);
 printf("Please enter the message");

 bzero(buffer, 256);
 fgets(buffer, 255, stdin);

 n = sendto(sock, buffer, strlen(buffer), 0,(struct sockaddr *)&server, sizeof(server));
 if(n < 0) error("Sendto\n");

 n = recvfrom(sock, buffer, 256, 0, (struct sockaddr *)&server, &length);
 if(n < 0) error("recvfrom\n");

 buffer[n] = '\0';

 write(1, "Got an ack: ",12);
 write(1, buffer,n);

}

void error(char *msg)

 perror(msg);
 exit(0);

}

'Education > Networking' 카테고리의 다른 글

TCP  (1) 2009.08.27
Posted by 초상큼발랄
l

Module

Education/Device Driver 2009. 8. 26. 19:46

Major :  장치의 종류
장치의 Interface
어떤 장치 드라이버와 연관이 되어 있는지를 알려준다.
장치 드라이버를 찾아주는 역할
Minor:  실제 장치들에 대한 식별
실제 장치 구분


 
<hello_mod.c>

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>

int hello_init(void)
{
printk("<0>Hello Module Loaded \n");
return 0;
}
void hello_exit(void)
{
printk("<0>Hello Module Unloaded\n");
return ;
}

module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");



<Makefile>

obj := hello_mod.o

KDIR := /lib/modules/$(shell uname -r)/bild               // directory module compile -> 모듈 설치
lib/moudles/ 해당 커널 버젼 Directory
PWD := $(shell pwd)

all :
$(MAKE) -C (KIDR)SUBDIRS=$(PWD)modules
clean:
rm -f *.ko
rm -f *.mod.*
rm -f Mod.*
rm -f *.o


 
#make

# insmod hello.ko
# lsmod | grep hello
# rmmod hello_mod
#lsmod |grep hello
dmesg | tail -2



Module shell Commands

1) insmod (insert module) 

2) rmmod (removemodule)

3) lsmod  (list of module)

4) modprobe ( dependency of module)
- depmod에 위해서 생성
- module 적재와 관련된 명령어
5) depmod 
- module's dependency 를 구축하기 위해 사용하는 모듈

 


 
Posted by 초상큼발랄
l