chapter 2: operating-system structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfkernel...

17
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th  Edition, Chapter 2: Operating-System Structures

Upload: vuongphuc

Post on 07-May-2018

217 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition,

Chapter 2: Operating-System Structures

Page 2: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.2 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

Administrivia

■ Read Chapter 3.

■ Kernel assignment to complete by start of class Friday:

● Clean kernel source:   cd linux­2.6.27.1; make mrproper

● Import kernel source into your own repository:

   svn import https://merlin.goucher.edu/svn/kelliher/linux­2.6.27.1

(Replace my username with YOURS)

● Remove unversioned kernel source:   cd ..; rm ­rf linux­2.6.27.1

Page 3: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.3 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

Administrivia, contd.

● Checkout versioned kernel source:

   svn co https://merlin.goucher.edu/svn/kelliher/linux­2.6.27.1

● Confirm that all is ok:   cd linux­2.6.27.1; svn statusshould execute quietly.

■ Read Programming Project 2.8 starting on pg. 93.

■ Read http://www.linuxchix.org/content/courses/kernel_hacking/lesson5.  What 

kernel file should actually be modified?

Page 4: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.4 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

Outline

■ Virtual machine examples.

■ Adding a syscall to Linux.

Page 5: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.5 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

Virtual Machines

■ A virtual machine takes the layered approach to its logical conclusion.  It treats hardware and the operating system kernel as though they were all hardware

■ A virtual machine provides an interface identical to the underlying bare hardware

■ The operating system host creates the illusion that a process has its own processor and (virtual memory)

■ Each guest provided with a (virtual) copy of underlying computer

Page 6: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.6 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

Virtual Machines History and Benefits

■ First appeared commercially in IBM mainframes in 1972■ Fundamentally, multiple execution environments (different operating 

systems) can share the same hardware■ Protect from each other■ Some sharing of file can be permitted, controlled■ Commutate with each other, other physical systems via networking■ Useful for development, testing■ Consolidation of many low­resource use systems onto fewer busier systems■ “Open Virtual Machine Format”, standard format of virtual machines, allows 

a VM to run within many different virtual machine (host) platforms

Page 7: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.7 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

Virtual Machines (Cont)

                             (a) Nonvirtual machine (b) virtual machine

Non­virtual Machine Virtual Machine

Page 8: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.8 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

Para-virtualization

■ Presents guest with system similar but not identical to hardware■ Guest must be modified to run on paravirtualized hardware■ Guest can be an OS, or in the case of Solaris 10 applications running in 

containers

Page 9: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.9 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

Solaris 10 with Two Containers

Page 10: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.10 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

VMware Architecture

Page 11: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.11 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

The Java Virtual Machine

Page 12: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.12 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

Operating-System Debugging

■ Debugging is finding and fixing errors, or bugs■ OSes generate log files containing error information■ Failure of an application can generate core dump file capturing memory of 

the process■ Operating system failure can generate crash dump file containing kernel 

memory■ printk() :

Page 13: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.13 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

Adding a Syscall to Linux

■ Three main elements:

● Assigning a number to the syscall, making it accessible from user space

● Adding it to the kernel syscall table, allowing the kernel to call the syscall

● Writing the syscall and adding it to the kernel.

Page 14: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.14 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

Adding a Syscall to Linux

■ Syscall path:

Page 15: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.15 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

Syscall Parameter Passing

■ Parameters passed in registers:_syscall1( long, diffjiffies, long, ujiffies );

printf( "difference is %lx\n", diffjiffies(jifs) );

■ Parameters passed by reference:

int access_ok( type, address, size );

unsigned long copy_from_user( void *to, const void __user

*from, unsigned long n );

unsigned long copy_to_user( void *to, const void __user

*from, unsigned long n );

Page 16: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

2.16 Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition

Additional Background:

■ http://www.ibm.com/developerworks/library/l­system­calls/

Page 17: Chapter 2: Operating-System Structuresphoenix.goucher.edu/~kelliher/s2009/cs325/l05.pdfKernel assignment to complete by start of class Friday: Clean ... Read . ... (virtual memory)Authors:

Silberschatz, Galvin and Gagne ©2009Operating System Concepts – 8th Edition,

End of Chapter 2