Docsity

Operating System Design Homework 2 - CS 3210, Assignments of Operating Systems

Toggle sidebar
bg1
CS 3210 Operating System Design
Spring 2005 y Hutto
Georgia Tech, College of Computing
Homework 2
DUE: 3:05 pm (class time) Tu 15 February 2005
Topics Covered:
• Processes
• Interrupts/Exceptions
• Timing
• Kernel Synchronization
Work individually on this. Please prepare printed solutions using the word processing software of your
choice to the following questions (no handwritten solutions accepted) and bring to class on the due
date. Answers should be short but concise. Questions amplify material from the lectures and the
assigned readings. Questions frequently require you to investigate Linux or OS features and
capabilities. Please make use of all available resources (web, man pages, kernel source, discussions
with staff, etc.). Most questions can be answered in a well-constructed paragraph or two. We aren’t
trying to kill you with the homeworks. These are mostly to acquaint you with some interesting
additional material. So have fun!
1. One of the many things the kernel does when executing a fork() system call (do_fork()) is to
allocate a new, unused process id (PID). By default, the maximum process ID is 32,767. Also certain
Ids are reserved for system-related processes and kernel threads. A longstanding UNIX tradition has
it that PIDs are allocated more or less sequentially so that PIDs are not immediately reused unless
not other PIDs are available. As a code-reading exercise, look at the surprisingly complicated
get_pid() kernel function in kernel/fork.c. Give a detailed explanation of what this code is doing
in English. I don’t want a blow-by-blow description that just mirrors the code. I want a higher-level
conceptual understanding of the code, expressed in English. What can you say about the
performance (execution time) of this code? What is the worst case for the algorithm? (Hint:
Web searches should be helpful on this one.)
2. Some interesting developments in the Linux thread model have occurred during the 2.5/2.6
development process. Two new, competing re-implementations were proposed: the Native Posix
Thead Library (NPTL) and the New Generation Posix Threads (NGPT). The NPTL implementation
was finally included in the new kernel. Read the following two articles and any other relevant material
you find and describe in about a page or so NPTL and explain why it is considered superior to
the old thread implementation (LinuxThreads) and to NGPT.
The Native Posix Thread Library for Linux1
Drepper, Molnar; Red Hat
February 2003 (Updated with disclaimer January 2005)
1 Note the opening rant by Drepper and Molnar (added last month): “This document is completely, utterly out of
date when it comes to descriptions of the limitations of the current implementation. Everybody referring to this document is either a
moron who hasn’t done her/his homework and researched the issue, or is deliberately misleading people as it happens too often with
publications done by the Evil from the North-West.” Despite this vigorous argument, I still think the paper is an interesting read and
useful in understanding the issues involved and how the kernel evolves. – Phil Hutto
pf2

Partial preview of the text

Download Operating System Design Homework 2 - CS 3210 and more Assignments Operating Systems in PDF only on Docsity!

CS 3210 Operating System Design

Spring 2005 y Hutto

Georgia Tech, College of Computing

Homework 2

DUE: 3:05 pm (class time) Tu 15 February 2005

Topics Covered:

  • Processes
  • Interrupts/Exceptions
  • Timing
  • Kernel Synchronization

Work individually on this. Please prepare printed solutions using the word processing software of your choice to the following questions (no handwritten solutions accepted) and bring to class on the due date. Answers should be short but concise. Questions amplify material from the lectures and the assigned readings. Questions frequently require you to investigate Linux or OS features and capabilities. Please make use of all available resources (web, man pages, kernel source, discussions with staff, etc.). Most questions can be answered in a well-constructed paragraph or two. We aren’t trying to kill you with the homeworks. These are mostly to acquaint you with some interesting additional material. So have fun!

  1. One of the many things the kernel does when executing a fork() system call (do_fork()) is to allocate a new, unused process id (PID). By default, the maximum process ID is 32,767. Also certain Ids are reserved for system-related processes and kernel threads. A longstanding UNIX tradition has it that PIDs are allocated more or less sequentially so that PIDs are not immediately reused unless not other PIDs are available. As a code-reading exercise, look at the surprisingly complicated get_pid() kernel function in kernel/fork.c. Give a detailed explanation of what this code is doing in English. I don’t want a blow-by-blow description that just mirrors the code. I want a higher-level conceptual understanding of the code, expressed in English. What can you say about the performance (execution time) of this code? What is the worst case for the algorithm? (Hint: Web searches should be helpful on this one.)
  2. Some interesting developments in the Linux thread model have occurred during the 2.5/2. development process. Two new, competing re-implementations were proposed: the Native Posix Thead Library (NPTL) and the New Generation Posix Threads (NGPT). The NPTL implementation was finally included in the new kernel. Read the following two articles and any other relevant material you find and describe in about a page or so NPTL and explain why it is considered superior to the old thread implementation (LinuxThreads) and to NGPT.

The Native Posix Thread Library for Linux^1 Drepper, Molnar; Red Hat February 2003 (Updated with disclaimer January 2005)

(^1) Note the opening rant by Drepper and Molnar (added last month): “This document is completely, utterly out of

date when it comes to descriptions of the limitations of the current implementation. Everybody referring to this document is either a moron who hasn’t done her/his homework and researched the issue, or is deliberately misleading people as it happens too often with publications done by the Evil from the North-West.” Despite this vigorous argument, I still think the paper is an interesting read and useful in understanding the issues involved and how the kernel evolves. – Phil Hutto

Linux Multithreading Advances Cooperstein November 2002

  1. Great care has gone into kernel coding so that everything operates properly when the jiffies global kernel variable “wraps around” (no Y2K problem for penguins). Explain precisely why the macros time_after() and time_before() avoid wrap-around problems. (Hint: Chapter 9 in Love takes you most of the way to the solution of this question but you will need to make the final step to justify the behavior of the macros.)
  2. Linux reader-writer spinlocks favor readers over writers. That is, if a read lock is held, then a writer arrives and waits, later arriving readers will be granted the lock ahead of the waiting writer. Look at the assembly code in Bovet & Cesati (page 171) and explain what specifically about the implementation favors readers? Can you suggest a modification to the code that would provide first-come first-served behavior for waiters? Why do you think the kernel writers implemented the lock with reader priority (favor)? What would it mean for the lock to favor writers?