운영체제 2023-03-29 수업정리

Flow

Thread


Thread

Thread를 사용하여 얻는 이점

Multithreaded Process

Multicore Programming


Concurrency

Parallelism

Amdahl's Law

Process vs Thread


Multithreading Models


User Thread vs Kernel Thread

비교

Many-to-One Model

Many-to-One Model

One-to-One Model

One-to-One Model

Many-to-Many Model

Many-to-Many Model

Two-Level Model

Two-level Model

Thread 생성 방식

Virtualization


The Crux of Problem : How to Provide the Illusion of Many CPU's?

Interleaving Multiple Process

Interleaving Multiple Process

Virtualizing the CPU

Virtualizing the CPU

OS creates the illusion that each process has its own CPU(and memory)

Memory Virtualization

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include "common.h"

int main(int argc, char *argv[]) 
{
	int *p = malloc(sizeof(int));
	assert(p != NULL);
	printf("(%d) address of p : %08x\n", getpid(), (unsigned)p);
	
	*p = 0;
	while(1) {
		Spin(1);
		*p = *p + 1;
		printf("(%d) p: %d\n", getpid(), *p);
	}
	return 0;
}