'Process Administration'에 해당되는 글 1건

  1. 2008.08.08 Chapter 8. 프로세스 관리
2008. 8. 8. 18:46

Chapter 8. 프로세스 관리


Process Administration

 

 

INDEX

_______________________________________

 

1. Process Information

2. Default Process Administration

3. Extenston Process Administration

_______________________________________

 

 

 

프로세스(Process) ?

- 실행중인 프로그램그램이다.

 

프로세스는 컴퓨터 내에서 실행중인 프로그램의 인스턴스이다. 이 용어는 몇몇 운영체계에

서 사용되는, "태스크"라는 용어와 의미상으로 가깝다. 유닉스나 몇몇 다른 운영체계에서

, 프로그램이 시작되면 프로세스도 시작된다. 태스크와 마찬가지로, 프로세스는 그 프로

세스가 추적 관리될 수 있게 하기 위한 특정한 데이터 셋이 관련되어 실행 중인 프로그램

이다. 여러 명의 사용자들에 의해 공유되고 있는 응용프로그램은 일반적으로 각 사용자들

의 실행단계에서 하나의 프로세스를 갖는다.

 

프로세스는 자프로세스라고도 불리는 서브프로세스를 시작시킬 수 있다. 자프로세스는 부

프로세스의 복제로서 부프로세스의 자원을 일부 공유하는데, 부프로세스가 종료되면 더

이상 존재할 수 없다. 프로세스들은 몇 가지 IPC 방식을 통하여 정보를 교환하거나 그들의

연산을 동기화할 수 있다.

 

IPC 방식의 대표적인 메쏘드는

      (a)Pipes named pipes

      (b)Message queueing

      (c)Semaphores,

      (d)Shared Memory

      (e)Socket

등이다.

 

 


1. 프로세스 정보(Process Information)

 

ps 명령어를 통해서 프로세스 정보를 확인할 수 있다. 이런 정보는 존재해야만 출력이 될

수 있다. 프로세스의 정보는 /proc 디렉토리에 하위에 프로세스 아이디(PID) 번호와 대응

이 되는 이름을 가진 디렉토리에 존재한다.

 

다음은 기본적인 프로세스 정보에 대한 내용이다.

- PID(Process Identification)

- PPID(Parent Process ID)

- UID/GID

- EUID/EGID

- Control Terminal

 

 

 

(1). 프로세스 정보가 존재하는 디렉토리

프로세스에 대한 정보는 /proc 디렉토리에 해당 프로세스의  PID 번호 디렉토리안에 정보

가 존재하게 된다.   이 디렉토리 안에 존재하는 파일들은 대부분 텍스트 파일로 되어 있지

않기 때문에 프로세스의 정보를 확인 할때 pCMD(: pfiles, pstack, ptree, ....)등의 명령

어를 사용해야 한다.

프로세스 정보 디렉토리 : /proc/PID

 

# admintool &

[1]    479     <----- admintool PID 번호 확인(479)

 

# ps

   PID TTY      TIME CMD

   467 pts/3    0:00 ksh

   479 pts/3    0:00 admintoo   <----- admintool PID 번호 확인(479)

 

# ls -ld /proc/479

 

admintool 종료(adminitool exit)

# ls -ld /proc/479

/proc/479: No such file or directory

 

 

 

[참고] procfs 특징

(a). /proc 디렉토리 하위에 PID 번호의 디렉토리가 생성되고 그안에 프로세스 정보가 쌓

     이게 된다. /proc/PID 디렉토리 하위에는 프로세스의 정보에 관련한 자세한 내용이

     파일과 디렉토리에 존재하게 된다.

(b). /proc/PID 디렉토리의 소유자는 프로세스를 실행시킨 사람의 소유이다.

 

 

 

[참고] 프로세스 정보를 자세하게 보기 위해서는 다음 파일을 참고 한다.

/root/docs/Reference/Process_CMD.txt

- 위의 문서중 pldd, pfiles, pstack, ptree, ptime 명령어는 반드시 알아 두자.

pldd     : 프로세스가 사용하고 있는 동적 라이브러리 확인

pfiles   : 프로세스가 사용하고 있는 파일들 확인

pstack   : 프로세스가 사용하고 있는 stack 공간 확인

ptree    : 프로세스 tree 구조 확인

ptime    : 프로세스가 실행된 시간 확인

 

 

 

(2). PID

 

프로그램을 실행 하면 프로세스가 되며, 각각의 프로세스를 식별하기 위해 할당되는 번호로

PID 번호가 할당 된다.

 

 

 

(3). 부모프로세스(PPID)의 의미 확인

 

- PPID(Parent PID)

 

# ps

   PID TTY      TIME CMD

   467 pts/3    0:00 ksh

 

# ksh

# ps

   PID TTY      TIME CMD

   467 pts/3    0:00 ksh

   490 pts/3    0:00 ksh

 

# ps -l

 F S   UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN TTY      TIME CMD

 8 S     0  467   465  0  40 20 d4f1f138    500 d4f1f1a4 pts/3    0:00 ksh

 8 S     0  490   467  0  50 20 d4f1e338    500 d4f1e3a4 pts/3    0:00 ksh

 

 

PID=467

------------+

            |

            | PID=490, PPID=467

            +----------------------

 

[그림] 자식프로세스, 부모프로세스

 

 

 

(4). UID/GID, EUID/EGID의 의미 확인

 

- UID(User Identification)

- GID(Group Identification)

- EUID(Effective UID)

- EGID(Effective GID)

 

 

 


(5). 제어 터미널의 의미 확인

 

제어 터미널 필드에 올수 있는 정보는 다음과 같다.

 

제어 터미널(Control Terminal)

/dev/pts/5

/dev/term/b

/dev/console

?

 

 

 

 

2. 프로세스 관리 (1)

 

Default Process Administration

- 프로세스 실행(Process Execution)

- 프로세스 확인(Process Verification)

- 프로세스 종료(Process Termination)

 

 

(1). 프로세스 실행

 

하나의 프로그램을 실행하면 하나의 프로세스가 된다. 프로세스는 2가지 방법 형태로 실행

이 가능하며 (a)첫번째 방식은 포그라이운드(fg, foreground)에서의 실행 이고, (b)두번째

방식은 백그라운드(bg, background)에서의 실행이다.

 

프로세스 실행 방법

(fg) # admintool

(bg) # admintool &

 

(Foreground Process)

 

fg  ksh

-----------------+                     +-----------------

                 |                     |

                 |  ksh      admintool |

                 +---------------------+

 

# admintool

# ls

 

 

(Background Process)

 

bg  ksh 

-----------------+---------------------+---------------------

                 |                     |

                 | ksh       admintool |

                 +---------------------+

 

# admintool &

[1] PID

# ls

(2). 프로세스 확인

 

실행된 프로세스를 확인할 때는 ps 명령어를 사용한다.

# ps -ef | grep inetd

 

(명령어 옵션 사용법)

# ps

# ps l         // long info

# ps -a        // user가 실행 시킨 모든 데몬

# ps -U 100 (# ps -U user01, # ps -U user01,user02,user03)

# ps -t pts/5          // TERM 5에서 실행 중인 프로세스

# ps -ef | grep inetd

 

[ps 명령어 출력 화면 해석]

# ps

PID TTY      TIME CMD

467 pts/3    0:00 ksh

 

----------------------------------------------------------------------------

종류    설 명

----------------------------------------------------------------------------

PID     프로세스 아이디(식별 번호)

TTY     제어 터미널

TIME    CPU 사용 누적 시간(Comunitive Time)

CMD     명령어

----------------------------------------------------------------------------

 

[ps -l 명령어 출력 화면 해석]

# ps -l

F S   UID   PID  PPID  C PRI NI   ADDR      SZ    WCHAN    TTY      TIME CMD

8 S   0     467  465   0 40  20  d4f1f138  500   d4f1f1a4 pts/3    0:00 ksh

 

----------------------------------------------------------------------------

종류    설 명

----------------------------------------------------------------------------

F        현재는 의미가 없음

S        프로세스의 상태정보(Process Status)

         - S : Sleeping, process is waiting for an event to complete.

         - O : Occupy, process is running on a processor.

         - R : Runnable, process is on run queue.

         - T : Stopped, either by a job control signal or because it is being traced

         - Z : Zombie, process terminated and parent not waiting

UID      프로세스 실행 사용자

PID      프로세스 아이디(식별 번호)

PPID     부모 프로세스 아이디(식별 번호)

PRI      프로세스 우선 순위(Prioty)

NI       NICE , 프로세스의 우선 순위를 조정하는 값

ADDR    프로세스의 메모리상의 주소

SZ       가상 메모리 크기

WCHAN    프로세스 락(lock) 또는 이벤트시에 사용하는 프로세스 휴식(sleep) 주소

TTY      제어터미널

TIME     CPU 사용 누적 시간

CMD      명령어

----------------------------------------------------------------------------

 

 

 

-----------------------------------------------------------------------------------

필드   

-----------------------------------------------------------------------------------

UID    The effective user ID of the process's owner.

 

PID    The process ID.

 

PPID   The parent process ID.

 

C      The processor utilization for scheduling. This field is not displayed when

       the -c option is used.

 

CLS    The scheduling class to which the process belongs:

      real-time, system, or timesharing. This field is included only with the -c

       option.

 

PRI    The kernel thread's scheduling priority. Higher numbers indicate a higher

      priority.

 

NI     The process's nice number, which contributes to its scheduling priority.

       Making a process nicer means lowering its priority.

 

ADDR   The address of the proc structure.

 

SZ     The virtual address size of the process.

 

WCHAN  The address of an event or lock for which the process is sleeping.

 

STIME  The starting time of the process (in hours, minutes, and seconds).

 

TTY    The terminal from which the process (or its parent) was started. A question

       mark indicates that there is no controlling terminal.

 

TIME   The total amount of CPU time used by the process since it began.

 

CMD    The command that generated the process.

-----------------------------------------------------------------------------------

 

[ps -ef 명령어 출력 화면 해석]

# ps -ef | more

UID     PID  PPID C  STIME     TTY      TIME CMD

root    0    0    0   10:01:51  ?        0:03 sched

----------------------------------------------------------------------------

종류    설 명

----------------------------------------------------------------------------

UID      프로세스 실행 사용자

PID      프로세스 아이디(식별 번호)

PPID     부모 프로세스 아이디(식별 번호)

STIME    프로세스 시작 시간(Start Time)

TTY      제어 터미널

TIME     CPU 실행 누적 시간

CMD      명령어

----------------------------------------------------------------------------

[참고] ps 명령어 옵션

# man ps

.....

     The ps command prints information  about  active  processes.

    Without  options, ps prints information about processes that

     have the same effective user ID  and  the  same  controlling

    terminal  as  the invoker. The output contains only the pro-

     cess ID, terminal identifier, cumulative execution time, and

     the   command  name.  Otherwise,  the  information  that  is

     displayed is controlled by the options.

 

     Some options accept lists as arguments. Items in a list  can

     be either separated by commas or else enclosed in quotes and

     separated by commas  or  spaces.  Values  for  proclist  and

     grplist must be numeric.

 

     -e     Lists information about every process now running.

 

     -f    Generates a full listing. (See below for significance

            of columns in a full listing.)

 

     -l    Generates a long listing. (See below.)

 

     -a     Lists information about all processes most  frequently

            requested: all  those  except  session  leaders  and

            processes not associated with a terminal.

 

     -t  term

            Lists only process data associated with term. Terminal

            identifiers are  specified as a device file name, and

            an identifier. For example, term/a, or pts/0.

 

     -u  uidlist

            Lists only process data whose effective user ID number

            or login name is given in uidlist. In the listing, the

            numerical user ID will be printed unless you give  the

            -f option, which prints the login name.

 

     -U  uidlist

            Lists information for processes  whose  real  user  ID

            numbers  or login  names  are  given  in uidlist. The

            uidlist must be a single argument in  the  form  of a

            blank- or comma-separated list.

......

 

 


[참고] 솔라리스 시스템의 모든 프로세스 구분

모든 프로세스 종류(Process Type)

- 데몬 (Daemon Process)

- 사용자 프로세스(User Process)

 

+-----------+ <-------+  

|           |         |

|  Daemon   |         |

|           |         |

|-----------| <-+     -e

|           |   |     |

| User Proc.|  -a,-t |

|           |   |     |

+-----------+ <-+ <---+

 

User proc

         t : term

        u : user

 

프로세스를 생성하는 것은 2종류가 있다. 사람 즉 유저가 생성하는 프로세스와 데몬이 생성하는 프로세서다.

그중에서 사용자가 생성하는 프로세스의 목록을 알고 싶다면 ps -a 명령어로 확인이 가능하고, 시스템의 모든 프로세스를 확인하고 싶다면 ps -e명령어로 확인이 가능하다.

 

[참고] Daemon 이란?

시스템을 위해 또는 서비스를 위해 백그라운드에서 동작하는 프로세스이다.

 

 

 

(3). 프로세스 종료

 

프로세스 종료 방법

# kill PID   (# kill -15 PID)

# kill -9 PID

 

* 시그널(Signal)

___________________________________________

 

1  SIGHUP   프로세세 재시작(HangUp)

2  SIGINT   인터럽트(Interrupt, <Ctrl + C>)

9  SIGKILL  강제 종료(force exit signal)

15 SIGTERM  정상 종료(exit)

___________________________________________

 

[참고] 시그널(Signal)이란?

프로세스가 생성하거나 또는 프로세스에게 보내는 비동기적 알림 이벤트이다. 대부분의

동작은 프로세스 종료(Exit), Core 파일 생성(Core), 프로세스 정지(Stop)등이다.

 

# man -s 3head signal

 

# kill -l                 // signal list 확인

# kill -l HUP

# kill -l 1

 

 

[참고] kill 명령어 사용법

# kill PID

# kill -15 PID

# kill -TERM PID

# kill -s term PID         // -s : 특별히 보낼 시그널을 지정 시그널 이름이나 번호가 온다.

# kill -s TERM PID

 

 

[EX] kill -9 명령어 실습

[TERM1] 사용자 윈도우

# telnet localhost

user01 사용자로 로그인

$ id

 

[TERM2] 관리자 윈도우

# w

  5:24오후  up  9:01,  4 users,  load average: 0.02, 0.01, 0.01

User    tty           login@  idle  JCPU   PCPU  what

.....

user01  pts/8         5:24오후                      -ksh

.....

 

# ps -U user01

   PID TTY      TIME CMD

  1185 pts/8    0:00 ksh

# kill -9 1185

 

 

[참고] pgrep 명령어

ps + grep

 

# ps -ef | grep   inetd

    root   186    1  0 08:24:03 ?        0:00 /usr/sbin/inetd -s

# pgrep  -l inetd

  186 inetd

# pgrep  -lf inetd

  186 /usr/sbin/inetd -s

 

 

[참고] pkill 명령어

ps + kill

 

# ps -ef | grep   inetd

# kill -1 inetd's PID

or

# pkill  -1 inetd

 

 

 

[참고] nice & renice

프로세스의 우선 순위 조정 명령어

- nice   : 프로세스의 실행 시킬때 우선 순위를 정의할 수 있다.

- renice : 실행중인 프로세스의 우선 순위를 정의할 때 사용한다.

 

 


3. 프로세스 관리 (2)

 

프로그램을 실행하면 한나의 프로세스가 뜨게 되고, 이것을 하나의 잡(Job)이라고 표시한

. 다음은 잡 단위로 관리하는 방법에 대한 소개이다.

 

 

(1). (Job) 실행

 

잡 실행 방법

- 포그라운드 실행 방법

- 백그라운드 실행 방법

 

         +-----bg-----+

         |            |

+-----fg-----+        |

|            |        |

|            |        |

|            |        |

|            |--------+

|            |

+------------+

 

[EX] 프로세스 실행

# sleep  500 &

[1]     576

 

# sleep  600 &

[2]     579

 

[참고]

[1]   : Job ID

576   : Process ID

 

 

 

(2). (Job) 확인 및 작업 이동

 

Process Verification

 

[EX] (Job) 작업 이동

# jobs

[2] +  Running                 sleep 600 &

[1] -  Running                 sleep 500 &

 

# fg %1

sleep 500

<Ctrl + Z>

^Z[1] + Stopped (SIGTSTP)        sleep 500 &

 

# bg %1

[1]     sleep 500 &

 

 

(3). (Job) 종료

 

프로세스() 종료(Process Exit)

# kill %1 (Process Termination)

# stop %1 (Process Stop)

 

- Ctrl+Z  (Foreground Process Stop)

- stop %1 (Background Process Stop)

 

 

[EX] 프로세스 종료

# kill %1

[1] + Terminated               sleep 500 &

 

# kill %2

[2] + Terminated               sleep 600 &

 

 

 

[참고] 솔라3리스에서 실시간 프로세스를 확인하는 명령어

sdtprocess (GUI, Graphic User Interface)

prstat     (CLI, Command Line Interface)

 

# sdtprocess

or

CDE -> pannel -> Desktop Control -> Find Process

 

sdtprocess 기능(Function)

- 정열하는 방법(CPU, MEM Sor2ting)

- Refresh 시간 지정 방법(Sampling Time)

- 프로세스 찾기(Find Process)

- 프로세스 종료(Process Kill)

 

# prstat

[참고] prstat 프로세스 모니터링

http://blog.naver.com/jwsanta?Redirect=Log&logNo=60009529440

http://blog.naver.com/jwsanta?Redirect=Log&logNo=60009529471

http://blog.naver.com/jwsanta?Redirect=Log&logNo=60009529513

 

 

[참고] UNIX 실시간 프로세스 확인 명령어

- SUN  Solaris : prstat, sdtprocess

- HP  HP-UX   : glance, top

- IBM  AIX     : topas, nmon

 

 

[참고] 유닉스 성능 점검 툴

- sar      system activity reporter

- vmstat   report virtual memory statistics

- iostat   report I/O statistics

- netstat  show network status

- mpstat   report per-processor or per-processor-set statistics


[
참고] 솔라리스 성능에 관련한 점검 툴 

[참고] 솔라리스 성능에 관련한 점검 툴

/root/docs/Reference/SolarisPerformanceAdminTool.txt

 

 

 

[참고] 시그널

 

# man -s 3head signal

     A signal is an asynchronous notification of an event. A sig-

     nal  is said to be generated for (or sent to) a process when

     the event associated with that signal first occurs. Examples

     of such events include hardware faults, timer expiration and

     terminal activity, as well as the invocation of the  kill(2)

     or  sigsend(2)  functions.   In some circumstances, the same

     event generates signals for multiple  processes.  A  process

     may  request  a  detailed  notification of the source of the

    signal  and  the  reason   why   it  was   generated.   See

    siginfo(3HEAD).

 

     Signals can be generated  synchronously  or  asynchronously.

     Events directly caused by the execution of code by a thread,

     such as a reference to an unmapped, protected, or bad memory

     can  generate  SIGSEGV or SIGBUS; a floating point exception

     can generate   SIGFPE;  and  the  execution  of  an  illegal

    instruction can generate SIGILL. Such events are referred to

     as traps; signals generated by traps are said to be synchro-

    nously  generated.  Synchronously generated signals are ini-

     tiated by a specific thread and are delivered to and handled

     by that thread.

 

     Signals may also be generated by calling kill(), sigqueue(),

     or  sigsend().  Events  such as keyboard interrupts generate

     signals, such as SIGINT, which are sent to the  target  pro-

     cess.  Such  events  are  referred to as interrupts; signals

     generated by interrupts are said to be  asynchronously  gen-

     erated. Asynchronously generated signals are not directed to

     a particular thread but are handled by an  arbitrary  thread

     that meets either of the following conditions:

 

        o  The thread is blocked in a call  to  sigwait(2)  whose

          argument includes the type of signal generated.

 

        o  The thread has a signal mask that does not include the

          type  of  signal generated. A process responds to sig-

           nals in similar ways whether it is using  threads   or

          it   is   using  lightweight  processes  (LWPs).  See

          thr_create(3THR). Each process may  specify  a  system

          action  to be taken in response to each signal sent to

           it, called the signal's disposition.  All  threads  or

          LWPs  in the process share the disposition. The set of

          system signal actions for  a  process  is  initialized

          from  that  of its parent. Once an action is installed

           for a specific signal, it  usually  remains  installed

          until another disposition is explicitly requested by a

           call to either  sigaction(), signal() or  sigset(), or

          until   the  process  execs().  See  sigaction(2)  and

          signal(3C). When a process execs,  all  signals  whose

          disposition  has  been set to catch the signal will be

           set to SIG_DFL. Alternatively, a process  may  request

           that the system automatically reset the disposition of

           a signal to  SIG_DFL after it  has  been  caught.  See

          sigaction(2) and signal(3C).

 

 

 

[참고] nice & renice

 

프로세스의 우선 순위 조정 명령어

- nice   : 프로세스의 실행 시킬때 우선 순위를 정의할 수 있다.

          (invoke a command with an altered scheduling priorit)

- renice : 실행중인 프로세스의 우선 순위를 정의할 때 사용한다.

 

 

 

(1). nice 명령어

 

     The nice utility invokes command, requesting that it be  run

     with a different system scheduling priority. The priocntl(1)

     command is a more general interface to scheduler functions.

 

     nice 명령어는 다른 시스템 스케줄링 우선순위가 동작을 요청할때

     사용하는 명령어이다.

 

     The invoking process (generally the user's shell) must be in

     a scheduling class that supports nice.

 

     사용자 쉘에서 사용하는 프로세스 요청은 스케줄링 클래스 중에

     존재해야 한다. 이때 nice 명령어를 사용할 수 있다.

 

     If the C shell (see csh(1)) is used, the full  path  of  the

    command  must be specified; otherwise, the csh built-in ver-

     sion of nice will be invoked. See csh Builtin below.

 

     csh을 사용한다면 nice 명령어의 전체 경로를 지정해야 한다.

     렇지 않으면 csh 내장명령어인 nice가 실행된다.

 

 

(명령어 형식)

# nice CMD

# nice -10 CMD

# nice --10 CMD

# nice -n 10 CMD

# nice -n -10 CMD

 

- 포그라운드로 프로그램을 실행하면 기본적인 NI 값은 20이다.

- 백그라운드로 프로그램을 실행하면 기본적인 NI 값은 24이다.

- "# nice CMD" 실행을 하면 NI 값은 10이 높아진다.

- "# nice --10 CMD" 실행을 하면 NI 값은 10이 낮아진다.

- "# nice -10 CMD" 실행을 하면 NI 값은 10이 높아진다.

 

NI --> 증가, PRI --> 증가, 우선순위 --> 낮아짐

NI --> 감소, PRI --> 감소, 우선순위 --> 높아짐

 

 

[EX] nice 명령어 실습

[TERM1]

# admintool &

# admintool

 

[TERM2]

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2329   561  0  40 20 d4eb6a50   2284 d5fbc94a 21:25:34 pts/6    0:00 admintool

 8 S     root  2328   561  0  52 24 d4f57858   2284 d5fb607a 21:25:28 pts/6    0:00 admintool

 

[TERM1]

admintool 종료 후

# nice admintool &

# nice admintool

 

[TERM2]

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2340   561  0  70 30 d4f57858   2284 d5fb65ba 21:27:40 pts/6    0:00 admintool

 8 S     root  2339   561  0  82 34 d4eb6a50   2284 d5fb607a 21:27:31 pts/6    0:00 admintool

 

[TERM1]

admintool 종료 후

# nice --10 admintool &

# nice --10 admintool

 

[TERM2]

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2366   561  0  40 10 d4f54e58   2284 d5f7c572 21:34:22 pts/6    0:00 admintool

 8 S     root  2365   561  0  40 14 d4e64748   2284 d5fb8d32 21:34:13 pts/6    0:00 admintool

 

 

[TERM1]

admintool 종료후

# nice -5 admintool &

# nice -5 admintool

 

[TERM2]

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2356   561  0  67 29 d4f54e58   2284 d5f8f14a 21:31:21 pts/6    0:00 admintool

 8 S     root  2357   561  0  55 25 d4e64748   2284 d5fb8d32 21:31:29 pts/6    0:00 admintool

 

 

 


(2). renice 명령어

 

     The renice command alters the scheduling priority of one  or

     more  running  processes.  By  default,  the processes to be

     affected are specified by their process IDs.

 

     renice 명령어는 하나 또는 그 이상의 프로세스의 스케줄링 우선

     순위를 조정하는 명령어이다.

 

     If the first operand is a number within the valid  range  of

    priorities  (-20  to 20), renice will treat it as a priority

     (as in all but the first synopsis form).  Otherwise,  renice

     will treat it as an ID (as in the first synopsis form).

 

     만약 첫번째 연산자가 숫자라면(우선순위 범위: -20 ~ 20) renice

     명령어는 우선순위를 다루게 된다. 그렇지 않다면, renice 명령어

     는 그것을 ID(PID)로 다루게 된다.

 

  Altering Process Priority

     Users other than the privileged  user  may  only  alter  the

    priority  of  processes they own, and can only monotonically

     increase their "nice value" within the range 0 to  19.  This

    prevents  overriding  administrative  fiats.  The privileged

     user may alter the priority  of  any  process  and  set  the

     priority to any value in the range -20 to 19. Useful priori-

     ties are: 19 (the affected  processes  will  run  only  when

     nothing else in the system wants to); 0 (the "base" schedul-

     ing priority),; and any negative value (to  make  things  go

     very  fast).  20  is  an  acceptable nice value, but will be

     rounded down to 19.

 

     권한이 있는 사용자들은 단지 자신의 프로세세에 대한 우선순위를

     조정할 수 있다. 그리고 "nice value" (value is 0 to 19) 명령어

     를 통해서 우선순위를 일정하게 증가만 시킬수 있다. 이것은 관리

     자의 명령어 수행과 중첩되는 것을 막아 준다.  권한이 있는 사용

     자 어떤 프로세스의 우선순위를 조정할 수 있을 것이다.  그리고

     우선순위를 설정하기 위한 값의 범위는 "-20 ~ 19"로 설정 할 수

     있다.

     19 => 일반적인 우선순위(시스템에서 영향을 받지 않는 경우)

     0  => "base" 스케줄링 우선순위

     negative value => 더 높은 우선순위를 나타냄

     20 => 사용할 수 있는 nice 값이다. 그러나 19로 설정할 수도 있

     .

 

 

(명령어 형식)

 

# renice 15 PID

# renice -15 PID

# renice -n 15 PID

# renice -n -15 PID

 

- 포그라운드로 프로그램을 실행하면 기본적인 NI 값은 20이다.

- 백그라운드로 프로그램을 실행하면 기본적인 NI 값은 24이다.

- "# renice CMD" 실행을 하면 현재 NI 값에 10이 더 높아진다.

- "# renice 10 CMD" 실행을 하면 NI 값은 기본값(20) 10이 더 높아진다.

- "# renice -10 CMD" 실행을 하면 NI 값은 기본값(20) 10이 더 낮아진다.

 

NI --> 증가, PRI --> 증가, 우선순위 --> 낮아짐

NI --> 감소, PRI --> 감소, 우선순위 --> 높아짐

 

 

[EX] renice 명령어 실습

[TERM1]

# admintool &

# admintool

 

[TERM2]

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  52 24 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  40 20 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice 5 2474     

# renice 5 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  55 25 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  55 25 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice 10 2474

# renice 10 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  70 30 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  70 30 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice 40 2474

renice: 40:getpriority: No such process

# renice 40 2475

renice: 40:getpriority: No such process

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  97 39 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  97 39 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

renice 명령어 다음에 있는 40 PID 번호로 인식했다. renice 명령어의 최대 범위는 20

지이다. 이것을 넘으면 renice 명령어를 그냥 실행 한 것과도 같아 진다. renice 명령어를

우선순위 값 없이 사용한다면 이전의 NI 값에 10을 더하게 된다. 하지만 NI의 최대 범위는

39를 넘을 수 없다.

 

아래와 같이 원래 우선순위로 조정한다.

 

# renice 4 2474

# renice 0 2475


# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474  561  0  52 24 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  40 20 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice 2474

# renice 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI     ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  82 34 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  70 30 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice 2474

# renice 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  97 39 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  97 39 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

renice 명령어 다음에 있는 40 PID 번호로 인식했다. renice 명령어의 최대 범위는 20
지이다. 이것을 넘으면 renice 명령어를 그냥 실행 한 것과도 같아 진다. renice 명령어를
우선순위 값 없이 사용한다면 이전의 NI 값에 10을 더하게 된다. 하지만 NI의 최대 범위는
39
를 넘을 수 없다.

아래와 같이 원래 우선순위로 조정한다.

 

# renice 4 2474

# renice 0 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  52 24 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  40 20 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice -10 2474

# renice -10 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  40 10 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  40 10 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice -19 2474

# renice -19 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  40  1 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  40  1 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

# renice -25 2474

# renice -25 2475

# pps admintool

 F S      UID  PID  PPID  C PRI NI    ADDR     SZ    WCHAN    STIME TTY      TIME CMD

 8 S     root  2474   561  0  40  0 d4e64748   2284 d5fb607a 22:17:42 pts/6    0:00 admintool

 8 S     root  2475   561  0  40  0 d4eb6350   2284 d5f61c12 22:17:47 pts/6    0:00 admintool

 

 renice 명령어를 통해서 NI 값의 최소 범위는 -19이다. 이것보다 더 큰 값을 쓰더라도 모

  -19로 인식된다.

 renice 명령어를 통해서 NI 값의 최소 범위는 -19이다. 이것보다 더 큰 값을 쓰더라도 모
-19로 인식된다.