E D R , A S I H C RSS

쓰레드에관한잡담

process scheduling .
1. real-time process - 1.hard real-time(), 2.soft real-time(vedio decoder )
2. time-sharing process


time-sharing .
Linux thread .
1. Kernel - 1. Kernel Thread, 2. LWT(Lightweight Thread)
2. User Thread


thread , context switch thread .
Linux fork() do_fork() Kernel , do_fork() user thread POSIX기 Mutex .


... 그고... ... POSIX thread thread .
. . .
... mutex ... 겠군... lock context switch .



... context switch PCB(Process Control Block) .
Assembly .
PCB process간 .
-> Zombie Process PCB .

~cpp 
void *thread(void *arg)
{
        int num = *(int *)arg;
        int i;

        for(i=1; i<=20; i++){
                pthread_mutex_lock(&mutex);
                printf("%d: sum+=%d\n", num, i);
                sum += i;
                sleep(1);
                pthread_mutex_unlock(&mutex);
        }
}

thread 10개    ,
 고 context switch 고 arg    .
arg 0~9까     .

pthread_mutex_lock   arg 0 .
  pthread   .
   arg   . .

Critical Section .
.
argument .
function argument stack 고, 개개 각각 stack . .
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:30:19
Processing time 0.0118 sec