Tyler Gaynair Lab 6 Score is out of 20
|
|
- Leona Ellis
- 5 years ago
- Views:
Transcription
1 Tyler Gaynair Lab 6 Score is out of 20 1.) Try the pthreads.cpp and sdlthreads_demo.cpp programs presented in Introduction. Modify the programs so that they run 3 threads ( instead of two ) and each thread runs a different function, displaying a different message. Copy-and-paste the source code as well as the outputs into your report. *Pthread Modified for 3 threads instead of 2 #include <pthread.h> #include <stdio.h> using namespace std; //The thread void *runner ( void *data ) char *tname = ( char * )data; printf("i am %s\n", tname ); pthread_exit ( 0 ); void *walker (void *data ) char *tname = (char * )data; printf("hows it %s\n", tname ); pthread_exit (0); void *jogger (void *data ) char *tname = (char * )data; printf("what is %s\n", tname ); pthread_exit (0); int main () pthread_t id1, id2, id3; //thread identifiers pthread_attr_t attr1, attr2, attr3; //set of thread attributes char *tnames[3] = "Thread 1", "going", "up" ; //names of threads //get the default attributes pthread_attr_init ( &attr1 ); pthread_attr_init ( &attr2 ); pthread_attr_init ( &attr3 ); //create the threads pthread_create ( &id1, &attr1, runner, tnames[0] ); pthread_create ( &id2, &attr2, walker, tnames[1] ); pthread_create ( &id3, &attr3, jogger, tnames[2] );
2 //wait for the threads to exit pthread_join ( id1, NULL ); pthread_join ( id2, NULL ); pthread_join ( id3, NULL ); *Pthread modified executed [ @csusb.edu@jbh3-1 Lab6]$ vi sdlthread_demomod.cpp [ @csusb.edu@jbh3-1 Lab6]$./pthreads_demomod I am Thread 1 Hows it going What is up [ @csusb.edu@jbh3-1 Lab6]$ *Sdl thread modified for 3 threads instead of 2. #include <SDL/SDL.h> #include <SDL/SDL_thread.h> #include <stdio.h> using namespace std; //The thread int runner ( void *data ) char *tname = ( char * )data; printf("i am %s\n", tname ); int walker ( void *data ) char *tname = ( char * )data; printf("howdy %s\n", tname ); int jogger (void *data ) char *tname = (char * )data; printf("my name is %s\n", tname ); int main () SDL_Thread *id1, *id2, *id3; //thread identifiers char *tnames[3] = "Thread 1", "Partner", "Tyler" ; //names of threads //create the threads id1 = SDL_CreateThread ( runner, tnames[0] ); id2 = SDL_CreateThread ( walker, tnames[1] );
3 id3 = SDL_CreateThread ( jogger, tnames[2] ); //wait for the threads to exit SDL_WaitThread ( id1, NULL ); SDL_WaitThread ( id2, NULL ); SDL_WaitThread ( id3, NULL ); *SDL modified thread running [ @csusb.edu@jb358-3 Lab6]$./sdlthread_demomod I am Thread 1 Howdy Partner My name is Tyler [ @csusb.edu@jb358-3 Lab6]$ The following example, sema1.cpp demonstrates the use of semaphores; it prints an "E" when entering and an "L" when leaving a critical section if the program is invoked with one or more parameters, otherwise it prints an "e" and an "l" respectively. In the program, SEM_DOWN() changes the semaphore sem_op to -1 ( waiting ), which decrements the semaphore value, and SEM_UP() changes it to 1, which increments the semaphore value so that the semaphore becomes available. Note that this sample program allows only a single binary semaphore per program, although we could extend it to pass the semaphore variable if we need more semaphores. The function set_semvalue( value ) initializes the semaphore value; if we set it to 0 and the first process executes a SEM_DOWN() then it has to wait until another process would execute a SEM_UP() to unlock the semaphore. Of course, here we only deal with one process; there's no need to use any semaphore. So the code is mainly to demonstrate the coding of semaphores. Sema1.cpp //sema1.cpp #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> #include <iostream> #include <stdio.h> using namespace std; static int sem_id; //semaphore id #if defined( GNU_LIBRARY ) &&!defined(_sem_semun_undefined) /* union semun is defined by including <sys/sem.h> */ #else /* according to X/OPEN we have to define it ourselves */ union semun
4 int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */ unsigned short *array; /* array for GETALL, SETALL */ /* Linux specific part: */ struct seminfo * buf; /* buffer for IPC_INFO */ ; #endif //initializes semaphore using SETVAL static int set_semvalue ( int val ) union semun sem_union;// sem_union; sem_union.val = val; if ( semctl ( sem_id, 0, SETVAL, sem_union ) == -1 ) return ( 0 ); return 1; //delete semaphore static int del_semvalue () union semun sem_union;// sem_union; sem_union.val = 1; if ( semctl ( sem_id, 0, IPC_RMID, sem_union ) == -1 ) return ( 0 ); return 1; static int SEM_DOWN () struct sembuf b; b.sem_num = 0; b.sem_op = -1; //P(), i.e. down() b.sem_flg = SEM_UNDO; if ( semop ( sem_id, &b, 1 ) == -1 ) cout << "Semaphore DOWN() failed!" << endl; return 1; static int SEM_UP() struct sembuf b; b.sem_num = 0; b.sem_op = 1; //V(), i.e. UP() b.sem_flg = SEM_UNDO; if ( semop ( sem_id, &b, 1 ) == -1 ) cout << "Semaphore UP() failed!" << endl; return 1; int main ( int argc, char *argv[] ) int i, pause_time;
5 char ce = 'e', cl = 'l'; srand ( ( unsigned int ) getpid() ); //seed RNG with process id sem_id = semget ( (key_t) 1234, 1, 0666 IPC_CREAT ); if ( argc > 0 ) if (!set_semvalue( 1 ) ) //process can enter CS cout << "Semaphore initialized failed!" << endl; exit ( EXIT_FAILURE ); if ( argc > 1 ) ce = 'E'; cl = 'L'; sleep ( 1 ); else if (!set_semvalue( 0 ) ) cout << "Semaphore initialized failed!" << endl; exit ( EXIT_FAILURE ); sleep ( 1 ); //process will be blocked initially //enter and leave critical section 10 times for ( i = 0; i < 10; i++ ) if (!SEM_DOWN () ) exit ( EXIT_FAILURE ); cout << ce; fflush ( stdout ); //entering critical section pause_time = rand() % 3; //simulate critical section sleep ( pause_time ); cout << cl; fflush ( stdout ); //leaving critical section if (!SEM_UP() ) exit ( EXIT_FAILURE ); pause_time = rand() % 2; sleep ( pause_time ); cout << endl << getpid() << " finished!" << endl; if ( argc > 0 ) sleep ( 2 ); del_semvalue (); exit ( EXIT_SUCCESS ); //signal other waiting process *Execute with./sema1 & [ @csusb.edu@jb358-2 Lab6]$./sema1 & [1] 9969 [ @csusb.edu@jb358-2 Lab6]$ elelelelelelelelelel 9969 finished! *Execute with./sema1 a [ @csusb.edu@jb358-2 Lab6]$./sema1 a ELELELELELELELELELEL finished! [ @csusb.edu@jb358-2 Lab6]$
6 sema1mod.cpp modified programs #include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/sem.h> #include <iostream> #include <stdio.h> using namespace std; static int sem_id; //semaphore id #if defined( GNU_LIBRARY ) &&!defined(_sem_semun_undefined) /* union semun is defined by including <sys/sem.h> */ #else /* according to X/OPEN we have to define it ourselves */ union semun int val; /* value for SETVAL */ struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */ unsigned short *array; /* array for GETALL, SETALL */ /* Linux specific part: */ struct seminfo * buf; /* buffer for IPC_INFO */ ; #endif //initializes semaphore using SETVAL static int set_semvalue ( int val ) union semun sem_union;// sem_union; sem_union.val = val; if ( semctl ( sem_id, 0, SETVAL, sem_union ) == -1 ) return ( 0 ); return 1; //delete semaphore static int del_semvalue () union semun sem_union;// sem_union; sem_union.val = 1; if ( semctl ( sem_id, 0, IPC_RMID, sem_union ) == -1 ) return ( 0 ); return 1; static int SEM_DOWN ()
7 struct sembuf b; b.sem_num = 0; b.sem_op = -1; //P(), i.e. down() b.sem_flg = SEM_UNDO; if ( semop ( sem_id, &b, 1 ) == -1 ) cout << "Semaphore DOWN() failed!" << endl; return 1; static int SEM_UP() struct sembuf b; b.sem_num = 0; b.sem_op = 1; //V(), i.e. UP() b.sem_flg = SEM_UNDO; if ( semop ( sem_id, &b, 1 ) == -1 ) cout << "Semaphore UP() failed!" << endl; return 1; int main ( int argc, char *argv[] ) int i, pause_time; char ce = 'e', cl = 'l'; srand ( ( unsigned int ) getpid() ); //seed RNG with process id sem_id = semget ( (key_t) 1234, 1, 0666 IPC_CREAT ); if ( argc > 1 ) argc = atoi(argv[1]); //if 1, proceed if (argc ==1) if (!set_semvalue( 1 ) ) //process can enter CS cout << "Semaphore initialized failed!" << endl; exit ( EXIT_FAILURE ); ce = 'E';
8 cl = 'L'; sleep ( 1 ); else if (!set_semvalue( 0 ) ) //process will be blocked initially cout << "Semaphore initialized failed!" << endl; exit ( EXIT_FAILURE ); sleep ( 1 ); //enter and leave critical section 10 times for ( i = 0; i < 10; i++ ) if (!SEM_DOWN () ) exit ( EXIT_FAILURE ); cout << ce; fflush ( stdout ); //entering critical section pause_time = rand() % 3; //simulate critical section sleep ( pause_time ); cout << cl; fflush ( stdout ); //leaving critical section if (!SEM_UP() ) exit ( EXIT_FAILURE ); //signal other waiting process pause_time = rand() % 2; sleep ( pause_time ); cout << endl << getpid() << " finished!" << endl; if ( argc > 0 ) sleep ( 2 ); del_semvalue (); exit ( EXIT_SUCCESS ); *Executed./sema1mod 0 then./sema1mod 1./sema1mod 0 ^C [1]+ Done./sema1 [ @csusb.edu@jb358-2 Lab6]$./sema1mod 1 ELELELELELELELELELEL finished! [ @csusb.edu@jb358-2 Lab6]$ XV6 Scheduling Proc.c modified printf cprintf("process %s with pid %d running\n", p->name, p->pid);
9 Lab3]$ vi proc.c Lab3]$ make qemu-nox gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall-Werror -fno-omitframe-pointer -fno-stack-protector -c -o pro proc.c: In function scheduler : proc.c:347:7: error: expected ; before swtch swtch(&(c->scheduler), p->context); ^~~~~ make: *** [<builtin>: proc.o] Error 1 [ @csusb.edu@jb359-1 Lab3]$ vi proc.c [ @csusb.edu@jb359-1 Lab3]$ make qemu-nox gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall-Werror -fno-omitframe-pointer -fno-stack-protector -c -o pro ld -m elf_i386 -T kernel.ld -o kernel entry.o bio.o console.os.o ide.o ioapic.o kalloc.o kbd.o lapic.o log.o main.o mp.o pici.o sleeplock.o spinlock.o string.o swtch.o syscall.o sysfile.o s.o trap.o uart.o vectors.o vm.o -b binary initcode entryother objdump -S kernel > kernel.asm objdump -t kernel sed '1,/SYMBOL TABLE/d; s/.* / /; /^$/d' > dd if=/dev/zero of=xv6.img count= records in records out bytes (5.1 MB, 4.9 MiB) copied, s, 19.9 MB/s dd if=bootblock of=xv6.img conv=notrunc 1+0 records in 1+0 records out 512 bytes copied, s, 356 kb/s dd if=kernel of=xv6.img seek=1 conv=notrunc records in records out bytes (179 kb, 175 KiB) copied, s, 38.0 MB/s which: no qemu in (/usr/local/matlab/r2018a/bin:/share/bin:/usr/:/opt/xilinx/14.7/ise_ds/ise/bin/ lin64:/opt/xilinx/14.7/ise_ds/c/opt/xilinx/docnav:/opt/xilinx/vivado/2017.2/bin:/ opt/xilinx/vivin:/opt/xilinx/vivado/2017.2/bin:/opt/xilinx/vivado_hls/2017.2/ bstudio/bin:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/psr/java/latest/ bin:/usr/local/matlab/r2018a/bin:/share/bin:/usr/:/opt/xilinx/14.7/ise_ds/ise/bin/ lin64:/opt/xilinx/14.7/ise_ds/c/opt/xilinx/docnav:/opt/xilinx/vivado/2017.2/bin:/ opt/xilinx/vivin:/opt/xilinx/vivado/2017.2/bin:/opt/xilinx/vivado_hls/2017.2/ bstudio/bin:/opt/android-sdk-linux/tools:/opt/android-sdk-linux/psr/java/latest/ bin:/usr/lib64/qt-3.3/bin:/usr/lib64/ccache:/usr/in:/usr/local/sbin:/usr/sbin:/ home/csusb.edu/ /bin) qemu-system-i386 -nographic -drive file=fs.img,index=1,media=disive file=xv6.img,index=0,media=disk,format=raw -smp 2 -m 512 xv6... cpu1: starting 1 cpu0: starting 0 sb: size 1000 nblocks 941 ninodes 200 nlog 30 logstart 2 inodestt 58 Process initcode with pid 1 running
10 Process init with pid 1 running Process init with pid 1 running Process init with pid 1 running init: starting sh Process init with pid 1 running
11 $ ls Process sh with pid 2 running P ailedcess sh with pid 5 running Process sh with pid 2 running $ ec: fail with pid 3 running exec ss sh with pid 3 running Process ls with pid 3 running Process ls with pid 3 running Process ls with pid 3 running Process ls with pid 3 running README cat Process ls with pid 3 running echo forktest grep init kill ln Process ls with pid 3 running ls
12 mkdir rm sh stressfs usertests Process ls with pid 3 running 416 wc cp zombie console myfile Process sh with pid 2 running Process sh with pid 2 running Now we write a dummy program named foo.c that creates some child processes and consumes some computing time: #include "types.h" #include "stat.h" #include "user.h" #include "fcntl.h" int main(int argc, char *argv[]) int k, n, id; double x = 0, z; if(argc < 2 ) n = 1; //default value else n = atoi ( argv[1] ); //from command line if ( n < 0 n > 20 ) n = 2; x = 0; id = 0; for ( k = 0; k < n; k++ ) id = fork (); if ( id < 0 ) printf(1, "%d failed in fork!\n", getpid() ); else if ( id > 0 ) //parent printf(1, "Parent %d creating child %d\n", getpid(), id ); // wait (); else // child printf(1, "Child %d created\n",getpid() ); break; for ( z = 0; z < ; z += 0.1 ) x = x * 89.64; // useless calculations to consume CPU time exit(); After Makefile is updated. [ @csusb.edu@jb359-1 Lab3]$ vim Makefile
13 Lab3]$ make ld -m elf_i386 -T kernel.ld -o kernel entry.o bio.o console.o exec.o file.o fs.o ide.o ioapic.o kalloc.o kbd.o lapic.o log.o main.o mp.o picirq.o pipe.o proc.o sleeplock.o spinlock.o string.o swtch.o syscall.o sysfile.o sysproc.o trapasm.o trap.o uart.o vectors.o vm.o -b binary initcode entryother objdump -S kernel > kernel.asm objdump -t kernel sed '1,/SYMBOL TABLE/d; s/.* / /; /^$/d' > kernel.sym gcc -fno-pic -static -fno-builtin -fno-strict-aliasing -O2 -Wall -MD -ggdb -m32 - Werror -fno-omit-frame-pointer -fno-stack-protector -c -o foo.o foo.c ld -m elf_i386 -N -e main -Ttext 0 -o _foo foo.o ulib.o usys.o printf.o umalloc.o objdump -S _foo > foo.asm objdump -t _foo sed '1,/SYMBOL TABLE/d; s/.* / /; /^$/d' > foo.sym./mkfs fs.img README _cat _echo _forktest _grep _init _kill _ln _ls _mkdir _rm _sh _stressfs _usertests _wc _cp _foo _zombie nmeta 59 (boot, super, log blocks 30 inode blocks 26, bitmap blocks 1) blocks 941 total 1000 balloc: first 629 blocks have been allocated balloc: write bitmap block at sector 58 dd if=/dev/zero of=xv6.img count= records in records out bytes (5.1 MB, 4.9 MiB) copied, s, 20.9 MB/s dd if=bootblock of=xv6.img conv=notrunc 1+0 records in 1+0 records out 512 bytes copied, s, 226 kb/s dd if=kernel of=xv6.img seek=1 conv=notrunc records in records out bytes (179 kb, 175 KiB) copied, s, 31.6 MB/s After running foo 4 in qemu-nox $ foo 4 Process sh with pid 2 running Process sh with pid 2 running
14 Process foo with pid 3 running Parent 3 creating child 4 Parent 3 creating child 5 Parent 3 creating child 6 Process foo with pid 5 running Process foo with pid 6 running Child 6 created Process foo with pid 5 running Process foo with pid 3 running Process foo with pid 5 running Process foo with pid 6 running Process foo with pid 5 running Process foo with pid 3 running Parent 3 creating chilprocess foo with pid 7 running Process foo with pid 5 running Process foo with pid 6 running Process foo with pid 7 running Process foo with pid 3 running d 7 Process foo with pid 7 running Process foo with pid 5 running Child 5 created Process foo with pid 6 running Process foo with pid 7 running Child 7 created Process foo with pid 6 running Process foo with pid 3 running Child 4 created Process foo with pid 3 running Process foo with pid 5 running
15 Process foo with pid 6 running Process foo with pid 5 running Process foo with pid 7 running Process foo with pid 3 running Process foo with pid 7 running Process foo with pid 5 running Process foo with pid 6 running Add in the file proc.h the struct proc> the timestamps and the priority: struct proc uint sz; // Size of process memory (bytes) pde_t* pgdir; // Page table char *kstack; // Bottom of kernel stack for this process enum procstate state; // Process state int pid; // Process ID struct proc *parent; // Parent process struct trapframe *tf; // Trap frame for current syscall struct context *context; // swtch() here to run process void *chan; // If non-zero, sleeping on chan int killed; // If non-zero, have been killed struct file *ofile[nofile]; // Open files struct inode *cwd; // Current directory char name[16]; // Process name (debugging) //add timestamps and others uint createtime; //process creation time int sleeptime; //process sleeping time int readytime; //process ready (RUNNABLE) time int runtime; //process running time int priority; //process priority int tickcounter; char dum[8]; Add to the function allocproc() in proc.c the timestamp statements (highlighted in blue): static struct proc* allocproc(void) struct proc *p; char *sp; acquire(&ptable.lock);
16 for(p = ptable.proc; p < &ptable.proc[nproc]; p++) if(p->state == UNUSED) goto found; release(&ptable.lock); found: p->state = EMBRYO; p->pid = nextpid++; p->createtime = ticks; p->readytime = 0; p->runtime = 0; p->sleeptime = 0; release(&ptable.lock); Running foo after updating the printf in proc.c cprintf("process %s with pid %d running with createtime %d\n", p->name, p->pid, p->createtime); $ foo 4 Process sh with pid 2 running with creattime 22 with creattime 997 with creattime 997 with creattime 997 with creattime 997 with creattime 997 with creattime 997 with creattime 997 with creattime 997 with creattime 997 with creattime 997 with creattime 997 with creattime 997 with creattime 997 with creattime 997 with creattime 997 with creattime 997 with creattime 997 Parent 3 creating child 4 Parent 3 creating child 5 Child 4 created Child 5 created
17 Parent 3 creating child 6 Parent 3 creating child 7 Process foo with pid 7 running with creattime 1008 Process foo with pid 7 running with creattime 1008 Child 7 created Child 6 created Process foo with pid 7 running with creattime 1008 Process foo with pid 7 running with creattime 1008 Process foo with pid 7 running with creattime 1008 Process foo with pid 7 running with creattime 1008 Process foo with pid 7 running with creattime 1008 Process foo with pid 7 running with creattime 1008 Process foo with pid 7 running with creattime 1008
18 Process Creation time looks consistent with process ids. Evaluation: I feel like I deserve a 20/20 on this project because I did every part fully and put a lot of effort into it. I learned how to further manipulate a makefile and read creationtimes on process ids. Score: 20/20
Diego Gamboa. cse 460: Operating Systems. Dr. Yu. Lab 8: Dining Philosophers and XV6 Process Priority.
Diego Gamboa. cse 460: Operating Systems. Dr. Yu Lab 8: Dining Philosophers and XV6 Process Priority. 1] Dining Philosophers and Deadlock. ** Try the following program type ^C run it for some time to check
More informationPaging. CS143A: Principles of operating systems - Fall 17. UC Irvine, California
Paging CS143A: Principles of operating systems - Fall 17 UC Irvine, California Designated initializer Remember designated initializers? 1 Designated initializer Remember designated initializers? static
More informationCompile and execute fifo1.cpp listed above. Try the Balady's anomaly examples discussed in class. Did you observe the Belady's anomaly?
Tyler Gaynair Lab9 Score out of 20 Compile and execute fifo1.cpp listed above. Try the Balady's anomaly examples discussed in class. Did you observe the Belady's anomaly? Fifo.cpp code // fifo1.cpp: First
More informationGabrielle Evaristo CSE 460. Lab Dining Philosophers and Deadlock
Gabrielle Evaristo CSE 460 Lab 8 1. Dining Philosophers and Deadlock Try dine1.cpp. Type to check the number of philosophers eating. What conclusion can you draw on the number of philosophers that can
More informationThe Process Abstraction. CMPU 334 Operating Systems Jason Waterman
The Process Abstraction CMPU 334 Operating Systems Jason Waterman How to Provide the Illusion of Many CPUs? Goal: run N processes at once even though there are M CPUs N >> M CPU virtualizing The OS can
More informationProcesses & Threads. Today. Next Time. ! Process concept! Process model! Implementing processes! Multiprocessing once again. ! More of the same J
Processes & Threads Today! Process concept! Process model! Implementing processes! Multiprocessing once again Next Time! More of the same J The process model! Most computers can do more than one thing
More informationProcesses and Threads
1 Programs and Processes 1.1 What is a program? At its simplest, a program is a collection of instructions that are to be executed by the CPU. The program begins life as source code and is, most commonly,
More informationA: We see the ps auxw execute and print on screen. The program holds the command in buffer then it is printed on screen.
Brian Duenas CSE 460 Lab 4 20 points Total 2. Process Pipes Q: What do you see when you execute "pipe1"? Why? We see the ps auxw execute and print on screen. The program holds the command in buffer then
More information1 Programs and Processes
1 Programs and Processes 1.1 What is a program? At its simplest, a program is a collection of instructions that are to be executed by the CPU. The program begins life as source code and is, most commonly,
More informationCS 385 Operating Systems Fall 2013 Homework Assignment 2 Inter-Process Communications and Synchronization
CS 385 Operating Systems Fall 2013 Homework Assignment 2 Inter-Process Communications and Synchronization Due: Tuesday October15 th at 3:00 P.M. via Blackboard. Optional hard copy may be submitted to the
More informationCS 385 Operating Systems Spring 2013 Homework Assignment 2 Third Draft Inter-Process Communications and Synchronization
CS 385 Operating Systems Spring 2013 Homework Assignment 2 Third Draft Inter-Process Communications and Synchronization Due: Thursday March 14 th at 3:00 P.M. via Blackboard. Optional hard copy may be
More informationGabrielle Evaristo CSE 460. Lab Shared Memory
Gabrielle Evaristo CSE 460 Lab 7 1. Shared Memory Use man to study each of the shared memory functions and write a brief description on the usage of each of them. o shmget (shared memory get): Allocated
More informationProcesses. Today. Next Time. ! Process concept! Process model! Implementing processes! Multiprocessing once again. ! Scheduling processes
Processes Today! Process concept! Process model! Implementing processes! Multiprocessing once again Next Time! Scheduling processes The process model! Most computers can do more than one thing at a time
More informationProcesses. q Process concept q Process model and implementation q Multiprocessing once again q Next Time: Scheduling
Processes q Process concept q Process model and implementation q Multiprocessing once again q Next Time: Scheduling The process model Computers can do more than one thing at a time Hard to keep track of
More informationProcesses (Intro) Yannis Smaragdakis, U. Athens
Processes (Intro) Yannis Smaragdakis, U. Athens Process: CPU Virtualization Process = Program, instantiated has memory, code, current state What kind of memory do we have? registers + address space Let's
More informationConcurrent Servers. Overview. In our current assignment we have the following changes:
Concurrent Servers Overview In our current assignment we have the following changes: Concurrent server Session command with an argument of the session name Shutdown command 2 Concurrent Server When a client
More information4. The Abstraction: The Process
4. The Abstraction: The Process Operating System: Three Easy Pieces AOS@UC 1 How to provide the illusion of many CPUs? p CPU virtualizing w The OS can promote the illusion that many virtual CPUs exist.
More informationUsing IPC: semaphores Interprocess communication using semaphores. Lecturer: Erick Fredj
Using IPC: semaphores Interprocess communication using semaphores Lecturer: Erick Fredj What is a 'semaphore'? A classical approach for restricting access to shared resources in multi-process environments
More informationChanges made in this version not seen in first lecture:
Scheduling 1 1 Changelog 1 Changes made in this version not seen in first lecture: 10 September: RR varying quantum examples: fix calculation of response/wait time on Q=2 10 September: add priority scheduling
More informationIntroduction. This project will focus primarily on processes.
Project 2 Processes Introduction This project will focus primarily on processes. In this project, you will become familiar with: 1. Locks for kernel-level data structures; concurrency. 2. Implementing
More informationProcesses. Today. Next Time. Process concept Process model Implementing processes Multiprocessing once again. Scheduling processes
Processes Today Process concept Process model Implementing processes Multiprocessing once again Next Time Scheduling processes The process model Most computers can do more than one thing at a time Hard
More informationThreads. Threads (continued)
Threads A thread is an alternative model of program execution A process creates a thread through a system call Thread operates within process context Use of threads effectively splits the process state
More informationCS5460/6460: Operating Systems. Lecture 9: First process. Anton Burtsev January, 2014
CS5460/6460: Operating Systems Lecture 9: First process Anton Burtsev January, 2014 Recap from last time Jumped to main() Allocated physical memory allocator kalloc() allocates a page of virtual memory
More informationThreads. What is a thread? Motivation. Single and Multithreaded Processes. Benefits
CS307 What is a thread? Threads A thread is a basic unit of CPU utilization contains a thread ID, a program counter, a register set, and a stack shares with other threads belonging to the same process
More informationCS3210: Isolation Mechanisms
CS3210: Isolation Mechanisms Lecture 4 Instructor: Dr. Tim Andersen 1 / 34 Administrivia Lab 2 on Virtual Memory Due Feb 10 (one of the trickiest labs!) (Feb 16) Quiz #1. Lab1-3, Ch 0-3, Appendix A/B (Feb
More informationCSPP System V IPC 1. System V IPC. Unix Systems Programming CSPP 51081
System V IPC 1 System V IPC System V IPC 2 System V IPC Overview System V IPC 3 System V InterProcess Communication (IPC) Provides three mechanisms for sharing data between processes message queues (similar
More information518 Lecture Notes Week 3
518 Lecture Notes Week 3 (Sept. 15, 2014) 1/8 518 Lecture Notes Week 3 1 Topics Process management Process creation with fork() Overlaying an existing process with exec Notes on Lab 3 2 Process management
More informationCS 537: Introduction to Operating Systems (Summer 2017) University of Wisconsin-Madison Department of Computer Sciences.
CS 537: Introduction to Operating Systems (Summer 2017) University of Wisconsin-Madison Department of Computer Sciences Final Exam Friday, August 11 th 2017 3 pm - 5:30 pm There are eighteen (18) total
More informationCS 3305 Intro to Threads. Lecture 6
CS 3305 Intro to Threads Lecture 6 Introduction Multiple applications run concurrently! This means that there are multiple processes running on a computer Introduction Applications often need to perform
More informationCS510 Operating System Foundations. Jonathan Walpole
CS510 Operating System Foundations Jonathan Walpole The Process Concept 2 The Process Concept Process a program in execution Program - description of how to perform an activity instructions and static
More informationOperating Systems, Final exam May 2016 Bachelor's Degree in Computer Science and Engineering
RULES: The final grades and the review dates will be anounced in Aula Global. The exam duration is two hours and a half. Books and notes are not allowed. A valid ID document will be necessary to submmit
More informationOPERATING SYSTEMS 3rd Homework
OPERATING SYSTEMS 3rd Homework Due on: Final Exam Day Submission: Send your homework through the e-mail: kurt@ce.itu.edu.tr In this homework, you will Learn to create threads Learn how to manage resources
More informationLecture 18. Log into Linux. Copy two subdirectories in /home/hwang/cs375/lecture18/ $ cp r /home/hwang/cs375/lecture18/*.
Lecture 18 Log into Linux. Copy two subdirectories in /home/hwang/cs375/lecture18/ $ cp r /home/hwang/cs375/lecture18/*. Both subdirectories have makefiles. The "sysv" subdirectory has an example/exercise
More informationPROCESSES. Jo, Heeseung
PROCESSES Jo, Heeseung TODAY'S TOPICS What is the process? How to implement processes? Inter-Process Communication (IPC) 2 WHAT IS THE PROCESS? Program? vs. Process? vs. Processor? 3 PROCESS CONCEPT (1)
More informationProcesses. Jo, Heeseung
Processes Jo, Heeseung Today's Topics What is the process? How to implement processes? Inter-Process Communication (IPC) 2 What Is The Process? Program? vs. Process? vs. Processor? 3 Process Concept (1)
More informationPRACTICAL NO : 1. AIM: To study various file management system calls in UNIX.
PRACTICAL NO : 1 AIM: To study various file management system calls in UNIX. Write a program to implement 1. Create a file 2. Delete a file 3. Link a file 4. Copy one file to another file 5. Read contents
More informationProject 3 Improved Process Management
Project 3 Improved Process Management Introduction This project will modernize process management in xv6. All process management will be impacted. New console control sequences will be implemented to support
More informationCOP 4604 UNIX System Programming IPC. Dr. Sam Hsu Computer Science & Engineering Florida Atlantic University
COP 4604 UNIX System Programming IPC Dr. Sam Hsu Computer Science & Engineering Florida Atlantic University Interprocess Communication Interprocess communication (IPC) provides two major functions/services:
More informationCS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University
CS 333 Introduction to Operating Systems Class 3 Threads & Concurrency Jonathan Walpole Computer Science Portland State University 1 Process creation in UNIX All processes have a unique process id getpid(),
More informationOperating systems fundamentals - B06
Operating systems fundamentals - B06 David Kendall Northumbria University David Kendall (Northumbria University) Operating systems fundamentals - B06 1 / 12 Introduction Introduction to threads Reminder
More informationINTER-PROCESS COMMUNICATION. UNIX Programming 2015 Fall by Euiseong Seo
INTER-PROCESS COMMUNICATION UNIX Programming 2015 Fall by Euiseong Seo Named Pipes Anonymous pipes can be used only between related processes Processes not from the same ancestor sometimes need to communicate
More informationMessage Queues, Semaphores, Shared Memory
Message Queues, Semaphores, Shared Memory Message Queues Basic idea of a message queue 1. Two processes can exchange information via access to a common system message queue. 2. A process places a message
More informationReading Assignment 4. n Chapter 4 Threads, due 2/7. 1/31/13 CSE325 - Processes 1
Reading Assignment 4 Chapter 4 Threads, due 2/7 1/31/13 CSE325 - Processes 1 What s Next? 1. Process Concept 2. Process Manager Responsibilities 3. Operations on Processes 4. Process Scheduling 5. Cooperating
More informationCS Lab 1 xv6 Introduction Setup and exercise
CS 1550 Lab 1 xv6 Introduction Setup and exercise CS 1550 Kernel Space vs User Space OS manages hardware, services and user processes CPU Memory (Address space) I/O devices (Disk, mouse, video card, sound,
More informationProject 1 System Calls
Project 1 System Calls Introduction In this project, you will become familiar with: 1. Using the xv6 Makefile 2. Using conditional compilation. 3. The xv6 system call invocation path. 4. Implementing a
More informationCS 350 : COMPUTER SYSTEM CONCEPTS SAMPLE TEST 2 (OPERATING SYSTEMS PART) Student s Name: MAXIMUM MARK: 100 Time allowed: 70 minutes
CS 350 : COMPUTER SYSTEM CONCEPTS SAMPLE TEST 2 (OPERATING SYSTEMS PART) Student s Name: MAXIMUM MARK: 100 Time allowed: 70 minutes Q1 (30 marks) NOTE: Unless otherwise stated, the questions are with reference
More informationSystem Programming. Process Control II
Content : by Dr. B. Boufama School of Computer Science University of Windsor Instructor: Dr. A. Habed adlane@cs.uwindsor.ca http://cs.uwindsor.ca/ adlane/60-256 Content Content 1 Terminating a process
More informationCS 333 Introduction to Operating Systems. Class 3 Threads & Concurrency. Jonathan Walpole Computer Science Portland State University
CS 333 Introduction to Operating Systems Class 3 Threads & Concurrency Jonathan Walpole Computer Science Portland State University 1 The Process Concept 2 The Process Concept Process a program in execution
More informationWeek 2 Intro to the Shell with Fork, Exec, Wait. Sarah Diesburg Operating Systems CS 3430
Week 2 Intro to the Shell with Fork, Exec, Wait Sarah Diesburg Operating Systems CS 3430 1 Why is the Shell Important? Shells provide us with a way to interact with the core system Executes programs on
More informationIntroduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar
Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar elgayyar@ci.suez.edu.eg Mahmoud El-Gayyar / Introduction to OS 1 Processes in Unix, Linux, and Windows Unix pre-empted
More informationPart II Processes and Threads Process Basics
Part II Processes and Threads Process Basics Fall 2017 Program testing can be used to show the presence of bugs, but never to show their absence 1 Edsger W. Dijkstra From Compilation to Execution A compiler
More informationCITS2002 Systems Programming. Creating a new process using fork() 1 next CITS2002 CITS2002 schedule
1 next CITS2002 CITS2002 schedule Creating a new process using fork() fork() is very unusual because it returns different values in the (existing) parent process, and the (new) child process: the value
More informationCSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Final Exam Questions (document version 1.1) WITH SELECTED SOLUTIONS
CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Final Exam Questions (document version 1.1) WITH SELECTED SOLUTIONS Overview The final exam will be on Tuesday, May 17, 2016 from
More informationLecture 4 Threads. (chapter 4)
Bilkent University Department of Computer Engineering CS342 Operating Systems Lecture 4 Threads (chapter 4) Dr. İbrahim Körpeoğlu http://www.cs.bilkent.edu.tr/~korpe 1 References The slides here are adapted/modified
More informationPROCESS MANAGEMENT. Operating Systems 2015 Spring by Euiseong Seo
PROCESS MANAGEMENT Operating Systems 2015 Spring by Euiseong Seo Today s Topics Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication
More informationUnix-Linux 2. Unix is supposed to leave room in the process table for a superuser process that could be used to kill errant processes.
Unix-Linux 2 fork( ) system call is successful parent suspended child created fork( ) returns child pid to parent fork( ) returns zero value to child; zero is the pid of the swapper/scheduler process both
More informationProcesses. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University
Processes Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu OS Internals User space shell ls trap shell ps Kernel space File System Management I/O
More informationThis is an open book, open notes exam. But no online or in-class chatting.
Principles of Operating Systems Fall 2017 Final 12/13/2017 Time Limit: 8:00am - 10:00am Name (Print): Don t forget to write your name on this exam. This is an open book, open notes exam. But no online
More informationPOSIX threads CS 241. February 17, Copyright University of Illinois CS 241 Staff
POSIX threads CS 241 February 17, 2012 Copyright University of Illinois CS 241 Staff 1 Recall: Why threads over processes? Creating a new process can be expensive Time A call into the operating system
More informationMultithreaded Programming
Multithreaded Programming The slides do not contain all the information and cannot be treated as a study material for Operating System. Please refer the text book for exams. September 4, 2014 Topics Overview
More informationUNIX IPC. Unix Semaphore Unix Message queue
UNIX IPC Unix Semaphore Unix Message queue 1 UNIX SEMAPHORE: Unix semaphore is not a single variable but an array of non-negative integer variables. Number of non-negative values: 1 to some system defined
More informationEPL372 Lab Exercise 2: Threads and pthreads. Εργαστήριο 2. Πέτρος Παναγή
EPL372 Lab Exercise 2: Threads and pthreads Εργαστήριο 2 Πέτρος Παναγή 1 Threads Vs Processes 2 Process A process is created by the operating system, and requires a fair amount of "overhead". Processes
More informationIntroduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras
Introduction to Operating Systems Prof. Chester Rebeiro Department of Computer Science and Engineering Indian Institute of Technology, Madras Week 03 Lecture 12 Create, Execute, and Exit from a Process
More informationInterrupts, Fork, I/O Basics
Interrupts, Fork, I/O Basics 12 November 2017 Lecture 4 Slides adapted from John Kubiatowicz (UC Berkeley) 12 Nov 2017 SE 317: Operating Systems 1 Topics for Today Interrupts Native control of Process
More informationCSE 380: Homework 2: Synchronization
CSE 380 Homework 2 1 CSE 380: Homework 2: Synchronization Due : Thursday, October 2, 2003 Submit a hardcopy solution of the problems in class on Oct 2, and submit code and documentation for the programs
More informationWindows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C.
Structure Unix architecture users Functions of the System tools (shell, editors, compilers, ) standard library System call Standard library (printf, fork, ) OS kernel: processes, memory management, file
More informationOperating Systems, laboratory exercises. List 2.
Operating Systems, laboratory exercises. List 2. Subject: Creating processes and threads with UNIX/Linux API functions. 1. Creating a process with UNIX API function. To create a new process from running
More informationCSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Midterm Exam Questions (document version 1.1)
CSCI 4210 Operating Systems CSCI 6140 Computer Operating Systems Sample Midterm Exam Questions (document version 1.1) Overview The midterm exam will be in class on Monday, March 28, 2016 from 10:00-11:45AM
More informationCompile the Hello World program
OS Project1 1 Hello World Writing a Hello World program #include header.h main ( int argc, char *argv[] ) { printf( Hello World!\n ); } Compile the Hello World program > gcc helloworld.c o helloworld 2
More informationCISC2200 Threads Spring 2015
CISC2200 Threads Spring 2015 Process We learn the concept of process A program in execution A process owns some resources A process executes a program => execution state, PC, We learn that bash creates
More informationCS 33. Architecture and the OS. CS33 Intro to Computer Systems XIX 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.
CS 33 Architecture and the OS CS33 Intro to Computer Systems XIX 1 Copyright 2018 Thomas W. Doeppner. All rights reserved. The Operating System My Program Mary s Program Bob s Program OS CS33 Intro to
More informationOS Lab Tutorial 1. Spawning processes Shared memory
OS Lab Tutorial 1 Spawning processes Shared memory The Spawn exec() family fork() The exec() Functions: Out with the old, in with the new The exec() functions all replace the current program running within
More informationCPSC 341 OS & Networks. Threads. Dr. Yingwu Zhu
CPSC 341 OS & Networks Threads Dr. Yingwu Zhu Processes Recall that a process includes many things An address space (defining all the code and data pages) OS resources (e.g., open files) and accounting
More informationCS 33. Architecture and the OS. CS33 Intro to Computer Systems XIX 1 Copyright 2017 Thomas W. Doeppner. All rights reserved.
CS 33 Architecture and the OS CS33 Intro to Computer Systems XIX 1 Copyright 2017 Thomas W. Doeppner. All rights reserved. The Operating System My Program Mary s Program Bob s Program OS CS33 Intro to
More informationInterprocess Communication. Bosky Agarwal CS 518
Interprocess Communication Bosky Agarwal CS 518 Presentation Layout Review Introduction Pipes 1. Using pipes 2. Working of pipes 3. Pipe Data Structure 4. Special pipefs File System 5. Creating and destroying
More informationPOSIX Semaphores. Operations on semaphores (taken from the Linux man page)
POSIX Semaphores A variable of type sem_t Example Declaration of a semaphore sem_t sem; Operations on semaphores (taken from the Linux man page) int sem_init(sem_t *sem, int pshared, unsigned int value);
More informationShared Memory Semaphores. Goals of this Lecture
Shared Memory Semaphores 12 Shared Memory / Semaphores Hannes Lubich, 2003 2005 Page 1 Goals of this Lecture Understand the design and programming of the System V Unix shared memory interprocess communication
More informationCS Operating Systems Lab 3: UNIX Processes
CS 346 - Operating Systems Lab 3: UNIX Processes Due: February 15 Purpose: In this lab you will become familiar with UNIX processes. In particular you will examine processes with the ps command and terminate
More informationpthreads CS449 Fall 2017
pthreads CS449 Fall 2017 POSIX Portable Operating System Interface Standard interface between OS and program UNIX-derived OSes mostly follow POSIX Linux, macos, Android, etc. Windows requires separate
More informationNYU Poly s Policy on Academic Misconduct:
Homework 1 Academic Honesty Aside from the narrow exception for collaboration on homework, all work submitted in this course must be your own. Cheating and plagiarism will not be tolerated. If you have
More informationOperating Systems. Lab. Class Project #5
Operating Systems Lab. Class Project #5 Project Plan 6 projects 0. Install xv6 1. System call 2. Scheduling 3. Memory 4. Virtual memory 5. Concurrency 1 6. Concurrency 2 Individual projects 2017-05-16
More informationOperating Systems Lab
Operating Systems Lab Islamic University Gaza Engineering Faculty Department of Computer Engineering Fall 2012 ECOM 4010: Operating Systems Lab Eng: Ahmed M. Ayash Lab # 3 Fork() in C and C++ programming
More informationProject 2: Shell with History1
Project 2: Shell with History1 See course webpage for due date. Submit deliverables to CourSys: https://courses.cs.sfu.ca/ Late penalty is 10% per calendar day (each 0 to 24 hour period past due). Maximum
More informationCS 475. Process = Address space + one thread of control Concurrent program = multiple threads of control
Processes & Threads Concurrent Programs Process = Address space + one thread of control Concurrent program = multiple threads of control Multiple single-threaded processes Multi-threaded process 2 1 Concurrent
More informationCS333 Project 1 Test Report Your Name Here
To obtain the L A TEX source for this document, change the file extension to.tex in the url. Testing Aside: Each student will need to provide their own screen shots or other test output as well as the
More informationShared Memory Memory mapped files
Shared Memory Memory mapped files 1 Shared Memory Introduction Creating a Shared Memory Segment Shared Memory Control Shared Memory Operations Using a File as Shared Memory 2 Introduction Shared memory
More informationCS 3113 Introduction to Operating Systems Midterm October 11, 2018
General instructions: CS 3113 Introduction to Operating Systems Midterm October 11, 2018 Please wait to open this exam booklet until you are told to do so. This examination booklet has 10 pages. You also
More informationCS 3113 Introduction to Operating Systems Midterm October 11, 2018
General instructions: CS 3113 Introduction to Operating Systems Midterm October 11, 2018 Please wait to open this exam booklet until you are told to do so. This examination booklet has 10 pages. You also
More informationCreating a Shell or Command Interperter Program CSCI411 Lab
Creating a Shell or Command Interperter Program CSCI411 Lab Adapted from Linux Kernel Projects by Gary Nutt and Operating Systems by Tannenbaum Exercise Goal: You will learn how to write a LINUX shell
More informationProcesses. Chester Rebeiro IIT Madras
Processes Chester Rebeiro IIT Madras Executing Apps (Process) ELF Executable (a.out) $gcc hello.c $./a.out Process Process A program in execution Most important abstraction in an OS Comprises of Code Data
More informationThis is an open book, open notes exam. But no online or in-class chatting.
Principles of Operating Systems Winter 2017 Final 03/22/2017 Time Limit: 8:00am - 10:00am Name (Print): Don t forget to write your name on this exam. This is an open book, open notes exam. But no online
More informationNote: The following (with modifications) is adapted from Silberschatz (our course textbook), Project: Producer-Consumer Problem.
CSCI-375 Operating Systems Lab #5 Semaphores, Producer/Consumer Problem October 19, 2016 Note: The following (with modifications) is adapted from Silberschatz (our course textbook), Project: Producer-Consumer
More informationConcurrent Programming. Concurrent Programming with Processes and Threads
Concurrent Programming Concurrent Programming with Processes and Threads Review The fork system call creates a process Memory and resources are allocated The exec system call allow a program to execute
More informationLSN 13 Linux Concurrency Mechanisms
LSN 13 Linux Concurrency Mechanisms ECT362 Operating Systems Department of Engineering Technology LSN 13 Creating Processes fork() system call Returns PID of the child process created The new process is
More informationProcesses. Johan Montelius KTH
Processes Johan Montelius KTH 2017 1 / 47 A process What is a process?... a computation a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other
More information#include <sys/types.h> #include <sys/wait.h> pid_t wait(int *stat_loc); pid_t waitpid(pid_t pid, int *stat_loc, int options);
pid_t fork(void); #include pid_t wait(int *stat_loc); pid_t waitpid(pid_t pid, int *stat_loc, int options); char **environ; int execl(const char *path, const char *arg0,..., (char *)0); int
More informationCS342 - Spring 2019 Project #3 Synchronization and Deadlocks
CS342 - Spring 2019 Project #3 Synchronization and Deadlocks Assigned: April 2, 2019. Due date: April 21, 2019, 23:55. Objectives Practice multi-threaded programming. Practice synchronization: mutex and
More informationOperating systems and concurrency - B03
Operating systems and concurrency - B03 David Kendall Northumbria University David Kendall (Northumbria University) Operating systems and concurrency - B03 1 / 15 Introduction This lecture gives a more
More informationA process. the stack
A process Processes Johan Montelius What is a process?... a computation KTH 2017 a program i.e. a sequence of operations a set of data structures a set of registers means to interact with other processes
More informationCSC 1600 Unix Processes. Goals of This Lecture
CSC 1600 Unix Processes q Processes Goals of This Lecture q Process vs. program q Context switching q Creating a new process q fork: process creates a new child process q wait: parent waits for child process
More information