# 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