New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

Introdctn to Operating Systems

by: Melissa Metz

Introdctn to Operating Systems EECS 678

Marketplace > Kansas > Elect Engr & Computer Science > EECS 678 > Introdctn to Operating Systems
Melissa Metz
GPA 3.74


Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Class Notes
25 ?




Popular in Course

Popular in Elect Engr & Computer Science

This 39 page Class Notes was uploaded by Melissa Metz on Monday September 7, 2015. The Class Notes belongs to EECS 678 at Kansas taught by Staff in Fall. Since its upload, it has received 8 views. For similar materials see /class/186793/eecs-678-kansas in Elect Engr & Computer Science at Kansas.

Similar to EECS 678 at KU

Popular in Elect Engr & Computer Science


Reviews for Introdctn to Operating Systems


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 09/07/15
Using the Debugger Michael Jantz Dr Prasad Kulkarni Debugger What is it a powerful tool that supports examination of your program during execution Idea behind debugging programs Creates additional symbol tables that permit tracking program behavior and relating it back to the source files Some common debuggers for UNIXLinux gdb sdb dbx etc GDB gdb is a tool for debugging C amp C code You can run a program stop it on any line or the start of a function examine various types of information like values of variables sequence of function calls amp change values of variables during execution You can call a function and trace the execu on Compilation for gdb Code must be compiled with the g option gcc g o file1 file1c file2c file3o Which files can you debug You can debug file1c file 2c you cannot debug file3o in the above example Non compatibility of 0 option optimization is not always compatible Reason Optimizer rearranges code Getting NACHOS Download a NACHOS tar file from here httppeopleeecskuedumjantz678labslab02 Use the terminal to untar the archive tar xvzf nachostargz IMPORTANT Notes on building NACHOS This archive of NACHOS uses libraries that are only available on the machines in Eaton Hall and will not build on other machines Also some additional setup of your local environment is necessary in orderto build this archive Open bashrc in an editor and add the following two lines 7 export PYTHONPATHusrlocallibpython25sitepackagesPYTHONPATH 7 export LDLBRARYPATHusrlocallibLDLlBRARYPATH Now source your bachrc file In a terminal type 7 source bashrc The commands in bashrc are executed every time you login to your EECS account Therefore you will only need to do this just this once Making and Testing NACHOS Make the NACHOS archive cd nachos make Sorry for all the warnings Test NACHOS cd test userprognachos x matmult2 Should See 7220 lt2 7220 lt1 Machine halting Ticks total 1353897 idle 2172 system 135820 user 1215905 Context switches 13548 Disk lO reads 0 writes 0 Console lO reads 0 writes 26 Paging faults 116 pageins 118 pageouts 0 Network lO packets received 0 sent 0 Cleaning up Using GDB with NACHOS Starting GDB gdb program The executable for NACHOS is in nachosuserprog So to start nachos under GDB from the nachostest directory type gdb userprognachos Breakpoints break b Sets a breakpoint in program execution tbreak tb temporary breakpoint Exists until it is hit for the first time Breakpoint syntax b linenumber b functionname b lineorfunction if condition b filename line number into breakpoints Gives information on all active breakpoints delete d Deletes the specified breakpoint number eg d 1 A Breakpoint in NACHOS NACHOS simulates an operating system in user space code Debugging a running instance of NACHOS can help you learn how NACHOS operates As an example say you want to learn about how NACHOS forks new processes Place a breakpoint at the SystemFork system call b SystemFork Running NACHOS Under GDB run r runs the loaded program under GDB Can also specify arguments and HG redirection now eg r arg1 arg2 lt input gt output In our case the program NACHOS simulates is provided as an argument r x matmult2 matmult2 is a simple matrix multiplication program It forks exactly one child process and NACHOS simulates the execution of both the parent and the child Common GDB Commands When you hit the breakpoint you should see Breakpoint 1 SystemFork at userprogsystemcallcc458 Now gdb has stopped execution of NACHOS Try the following commands list I will list the source code around where execution has stopped Alternatively l fromlinenumber toIinenumberwill display the source code in between two given line numbers backtrace bt prints a backtrace of all stack frames From this you can tell how you got to where you are from the main The output here says you are in SystemFork which was called from dosystemcall which was called from ExceptionHandler etc etc o This is very helpful in determining the control flow of a given functionality in NACHOS Using the Frame Stack GDB currently has the SystemFork frame selected Use the info command to list information about the frame info args print the arguments passed into this frame info locals print the local arguments for this frame help info shows you everything info can tell you Additionally print information about other stack frames using up n Select the frame n levels up in the call stack towards main down n Select the frame n levels down in the call stack you must have used up in order to come back down After you select a new frame use info as described above to display information about the frame Control Flow continue c Continue until the next breakpoint is reached the program terminates or an error occurs Don39t use this just yet we39ve got a few more commands to try next n Execute one instruction Step over function calls step 3 Execute one instruction Step into function calls kill k Kills the program being debugged does not exit gdb preserves everything else from the session ie breakpoints Inspecting and Assigning Continue to the end of the SystemFork function Set a breakpoint on the line of the final return statement in SystemFork and use continue Now if you read the code in this function you39ll see it creates a new Thread t using the tgtFork method To look at t39s properties or any object39s use the following print p t Prints the value of some variable whatis t Prints the type ofz ptype t Prints fields for the type t Inspecting and Assigning cont Try these commands on the newly created Thread object whatis t Tells us the type oft ptype Thread Displays all the fields for the Thread class p tgtThreadlD Prints the ThreadlD of the newly created thread Now you can set this t39s ThreadlD using set var set var tgtThreadlDn Sets the tgtThreadlD value to n n should be an integer Finishing Up To finish this example continue until matmult2 and subsequently the NACHOS simulation finishes Notice the difference in the output The first couple lines show the ThreadlD39s of the threads NACHOS executed and their return values One of these should correspond to the ThreadlD you set in the SystemFork system call while debugging Type quit or ltctrldgt to exit gdb GDB References The Unix manual is a good quick reference for common GDB commands At a terminal type man gdb While running GDB help will give you any information you need for any command help h command If you need to do some heavy lifting with GDB the official documentation for users is at this website httpsourcewareorggdbcurrentonlinedocsgdbtochtml Text Editors for Programmers Dr Prasad Kulkarni Michael Jantz Some Common Editors Lightweight Ul limited features pico nano Heavier Ul limited features gedit kate Heavier Ul good features customizable Eclipse Anjuta Lightweight Ul good features customizable emacs vim Real Programmers name REAL PRCGRAHMERS x155 Emacs THE DTanchE szrzs VHICH Acme LENSES THAT WDPPNTHE R NW3RD camost THE va Dcruznmonwe cosmc HANDS ANDLFTHE OFTHE 57w cuzaams RAVE mums THEM To DEUle was swears 5mm THE DRWE RATHER TN THE my mwaes AND rm m 955ka EFL ITquot 39 39 r w a r4 r 7 E 7quot rarer mus nonwm 95 Poems 7F HIMWPKLSSUKE AM mm ExcusE HE BUT REAL WOGRMHERS USE BUTrERmEs NM E COURSE THERES Nu Ems COHMAND TU DOTHAT OH YEAH Goon at c m nmmg WEB r WWW MACS Focus On Vim xemacs an extension of emacs Slides are provided but this lab will cover only Vim Using Vim on a Simple Example Goto httppeopleeecskuedumj antz67 81abs1ab01 Make a directory for this lab and save simplec simple h and makefz le in this directory Save vimrc as vimrc in your home directory Use my to rename the le my Vimrc Vimrc Vimrc A collection of Vim commands run each time you start Vim Used to set mappings options that are not otherwise set by default Using Vim to Create amp Edit a File Start a session Vim simplec Press 39i39 to enter insert mode Now type any text you want 39Ese39 to enter command mode 39Wq39 to write changes and eXit the session Vim Modes of Operation Command Mode Input Mode Visual Mode V V ctrl V Command Visual Escape Escape 1 i A a O o R r Input Essential Commands e le Edit le in a new buffer 39 2W Save any modi cations to the current buffer 0 Quit Vim If you have modi cations you do not want to save use q Command Mode Navigation 0 Reopen simplec 7 Use j k l and h to navigate around the le as shown This may take awhile get used to but is very nice once you have it down 7 For faster page scrolling use ltcbgt and ltcfgt for page up and page down 0 I ve mapped these commands to spacebar and backspace in my vimrc 3 l l l kl 3 Input Mode The following commands switch to input mode i characters inserted just before the cursor position 1 characters inserted at the beginning of the line a characters inserted just after the cursor position A characters appended to the end of the line o characters inserted in a new line below the cursor O characters inserted in a new line above the cursor C Often overlooked deletes the line after the cursor position and start inserting characters at this position After you39re done editing press Escape to go back to command mode and w to write the changes Common Editor Commands Cutcopypaste in command mode dd cut a line of text yy copy yank a line of text Pp paste a line of text above below the cursor position Commands in Vim can be applied to multiple lines by typing the number of lines you want before the command 12dd cuts 12 lines of text 4j moves the cursor down 4 lines Common Editor Commands cont gqltmotion commandgt Format a block of code to comply with textwidth setting ltmotion commandgt is any of the commands to move the cursor ie j k h and l See example in simplec Format a block of code to correspond to tabbing conventions See example in simplec Searching w0rd Search for occurrences of word Cursor jumps to the next occurrence of word nN jump to the next previous occurrence of word w0rd search initially jumps to previous occurrence of word set ic ignore case nohlsearch to turn off highlighting from last search Mapped to nh in Vimrc FindReplace 0 s searchf0rreplacewith Variations s s r g Replace every occurrence on the line not just the rst s sr g Replace every occurrence in the current buffer s sr g 12 Replace for the next 12 lines s srgc Replace but get con rmation before doing so s srgi Ignore case When searching for s Setting the Mark ma Sets the mark a to the current cursor position a is not unique any alphanumeric character can be used Now pressing a in command mode returns you to the position marked by a Helpful for getting back to hard to nd sections of code quickly See the example in simplec that shows how it can be used with the ndreplace command to comment out large sections of code da Deletes the mark a Buffers Vim allows you to edit multiple les in one session using buffers ltcwgt V to split the screen vertically ltcwgt s to split the screen horizontally ltcwgt W to switch to the other screen VSeX splits the screen vertically or horizontally and opens a le explorer in the new screen Select sirnpleh to open it in the new screen Installing Buffer Explorer Vim has builtin commands to work with its open buffers but there is a plugin that allows you to visualize and navigate the open buffers Goto httpvimsourceforgenetscriptsscriptphpscriptid42 Download the latest version of bufexplorerzip and extract it In your home directory if a vim directory does not exist create it ls a v 0 If vim is not present do mkdir vim Now move the contents of the extracted bufexplorer folder into vim mv bufexplorerdoc bufexplorerplugin vim Inside your vim session do 0 helptag vimdoc Quit and reopen vim Buffer Explorer be Opens the buffer explorer in the current screen Allows you to navigate as in command mode and select a buffer Also can press the number of the buffer to select a buffer Tagging the Source Big advantage to Vim and other more sophisticated editors is its integration with a source code tagging program Inside a terminal goto the directory of the simple source and type ctags R Should create a le named tags Now reopen simplec in Vim Using Tags With Vim ltcgt With your cursor over a variable jump to the declaration of that variable ltctgt Having jumped to a declaration go back to the spot you jumped from You can use ltcgt multiple times before using ltctgt The functionality operates like pushing and popping frames on a stack Extremely helpful for browsing and learning large programs Colors Colorsehemes can be downloaded from httpWwwcscmuedumaverickVimColorSch Current default colorsehemes for EECS machines are in usrshareVimVim72colors Set a new colorseherne with colorscherne name Vim Resources Vim Tips Wiki httpVimWikiacomwikiMainPage Vim Cookbook httpwwwouallinecomVimcookhtml Slashdot comments discussing Vim tips httpaskslashdotorgarticleplsid081 10620t For everything else just use Google


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Anthony Lee UC Santa Barbara

"I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

Bentley McCaw University of Florida

"I was shooting for a perfect 4.0 GPA this semester. Having StudySoup as a study aid was critical to helping me achieve my goal...and I nailed it!"


"Their 'Elite Notetakers' are making over $1,200/month in sales by creating high quality content that helps their classmates in a time of need."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.