3 Pages

l14_Processes

Course: CS 375, Fall 2009
School: Evansville
Rating:
 
 
 
 
 

Word Count: 952

Document Preview

System UNIX Programming Lecture 14: Processes Lecture 14: Processes Introduction Outline Introduction to Processes Creating New Processes Reference BLP: Chapter 11 AUP: Chapter 5 man pages: getpid, getppid, system, wait, waitpid, fork, exec 1 Suppose we are writing an application that requires several matrix operations, or we want to produce a nice graph, or convert an image from GIF to PNG...

Register Now

Unformatted Document Excerpt

Coursehero >> Indiana >> Evansville >> CS 375

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
System UNIX Programming Lecture 14: Processes Lecture 14: Processes Introduction Outline Introduction to Processes Creating New Processes Reference BLP: Chapter 11 AUP: Chapter 5 man pages: getpid, getppid, system, wait, waitpid, fork, exec 1 Suppose we are writing an application that requires several matrix operations, or we want to produce a nice graph, or convert an image from GIF to PNG formats, etc. We could either: (1) write the required routines from scratch, (2) find and use library routines that do the work, or (3) use existing programs such as octave, gnuplot or the PNM utilities. 2 Lecture 14: Processes Introduction Lecture 14: Processes Introduction The third approach can be very powerful. It is often the easiest method as well. Why not use an existing utility that does what I need and I know to be efficient and robust? UNIX allows us run other programs from our program and communicate with these programs using a number of different interprocess communication (IPC) methods. 3 UNIX allows us to do this in a manner that is completely transparent to the user of our program. That is, we can use gnuplot to produce our graphs, but the user does not necessarily need to know that. In this chapter we learn to run other programs from our program. In Chapters 13-15 we will learn how to communicate (pass data) with these other programs. 4 Lecture 14: Processes What Is A Process? Lecture 14: Processes Parent and Child Processes A program is a collection of instructions and data kept in an file. A process is a running program. It consists of instruction, user data, and system data segments. The instruction and user data segments are initialized from the program. System data includes the current directory, open file descriptors, total CPU time, etc. 5 A new child process is created by the kernel on behalf of a parent process (via fork()). A child inherits most of the system data from the parent. For example, files that are open by the parent, will also be open to the child. Each process has a unique process-ID (a positive int). getpid() and getppid() can be used to find the current and parent process IDs. The init process has ID 1. 6 Lecture 14: Processes Process Groups Lecture 14: Processes Additional Process Info Each process is a member of a unique process group with its own process group ID (PGID). When a process is created it is a member of its parent's process group. One process is the process group leader. The PGID is the same as the leader PID. Only one process group is the foreground process group. The terminal device driver sends tty signals (interrupt, quit, etc) to each process in the foreground process group. 7 At the command line use "ps ajx" to list the PIDs, PPIDs and PGIDs of all processes. A parent may wait for a child to terminate by using the wait() or waitpid() routines. If a child ends before the parent calls wait(), then the child lives on as a "zombie" process until the parent wait() calls or ends. If a parent ends, a child's parent process ID is set to 1. (The child is adopted by init.) 8 Lecture 14: Processes Process Creation: system() Lecture 14: Processes Process Creation: fork/exec The system() function can be used to run another program (and thereby create a new process) from an existing process: system("program_name"); The parent process waits until the program completes. (See sys_xmpl.cpp) The program is run just as if the following had been entered at the command prompt: sh -c program_name 9 The system() function is built upon the fork(), exec() and wait() routines. fork() creates a child process that is a clone of the parent (identical instruction, userdata, and system-data segments). The exec() routine reinitializes a process from a designated program (file on disk). fork() & exec() are usually used together. 10 Lecture 14: Processes The exec() System Calls Lecture 14: Processes The exec() System Calls There are six exec() calls. First execl(): int execl(char *path, char *arg0, ..., char *argn, (char *)0); Here is an example: execl("/bin/ls", "ls", "-al", "/tmp", 0); exec() is the only way to execute a program under UNIX. (See exc_xmpl.cpp) Other exec() calls are execlp(), execle(), execv(), execvp() and execve(): Recall that a new process is not created by exec(). The code and user-data segments are reinitialized from the indicated program. The system data segment is not overwritten. 11 execv*() routines expect the arguments to be passed in an array. exec*p() routines look for the program in the PATH. exec*e() routines pass a pointer to a new environment array (instead of a copy). 12 Lecture 14: Processes The fork() System Call Lecture 14: Processes ...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Evansville - CS - 375
UNIX System Programming Lecture 13: DebuggingLecture 13: Debugging Types of ErrorsOutline Types of Programming Errors Debugging Methods Using gdbSpecification errors occur when the program specifications are not understood. The program a
Evansville - CS - 375
UNIX System Programming Lecture 12: Development ToolsLecture 12: Development Tools make and MakefilesOutline make and Makefiles Source code control Writing a man pagemake (and makefiles) is used to determine which pieces of a large progr
Johns Hopkins - AAS - 207
%!PS-Adobe-2.0 %Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software %Title: dhpost_207.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %DocumentFonts: Helvetica CMR6 CMMI6 Helvetica-Bold CMR5 CMSY5 CMSY6 %+ CMMI5 %EndComments %DVIP
Johns Hopkins - AAS - 207
Searching for Radial Velocity Variations in CarinaeRosina C. Iping (CUA/NASA/GSFC), George Sonneborn, Ted R. Gull (NASA/GSFC), Stefan Ivarsson, Krister Nielsen (CUA/NASA/GSFC)The Luminous Blue Variable Carinae has long been suspected to be a mas
Johns Hopkins - AAS - 207
Collaborators Ignasi Ribas Laurence DeWarf Scott Engle Ryan Hamilton Manuel Gdel Marc Audard Graham Harper Brian Wood Manfred CuntzUniversity of Barcelona Villanova University Villanova University Villanova University PSI, CH ETHZ, CH Univ. of Colo
Johns Hopkins - AAS - 207
The Helium II Lyman ForestGerard Kriss STScIWhat We Can Learn from Observations of He II Absorption Use the ratio of He II and H I column densities to ascertain the shape of the ionizing spectrum. Do stars or quasars dominate the radiation fie
East Los Angeles College - GPB - 0607
Computer Science Tripos Part IB and Part II(General)Group Projects 20062007<group-project@cl.cam.ac.uk> Project Briefing Michaelmas 2006 Alan Blackwell & Ross Anderson1. TimetableCandidates for Part IB and Part II(General) of the Computer Scie
Syracuse - CIS - 623
%!PS-Adobe-2.0 %Creator: dvipsk 5.58f Copyright 1986, 1994 Radical Eye Software %Title: syl.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %EndComments %DVIPSCommandLine: dvips syl %DVIPSParameters: dpi=300, comments removed %DVIPSSource:
Syracuse - CIS - 650
%!PS-Adobe-2.0 %Creator: dvips(k) 5.78 Copyright 1998 Radical Eye Software (www.radicaleye.com) %Title: syllabus.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %DocumentFonts: CMCSC10 CMR12 CMBX10 CMR10 CMSS10 CMTI10 CMMI10 CMR8 %+ CMR6 C
Syracuse - CIS - 650
%!PS-Adobe-2.0 %Creator: dvips(k) 5.78 Copyright 1998 Radical Eye Software (www.radicaleye.com) %Title: hw1.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %DocumentFonts: CMR10 CMBX12 CMTI10 CMMI10 CMSY10 CMSY8 CMMI8 CMR8 %EndComments %DV
Syracuse - CIS - 650
%!PS-Adobe-2.0 %Creator: dvips(k) 5.78 Copyright 1998 Radical Eye Software (www.radicaleye.com) %Title: hw1-soln3.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %DocumentFonts: CMR10 CMBX12 CMMI10 CMSY10 CMTI10 CMSY8 CMMI8 CMR8 %+ CMBX10
Syracuse - CIS - 650
%!PS-Adobe-2.0 %Creator: dvips(k) 5.78 Copyright 1998 Radical Eye Software (www.radicaleye.com) %Title: hw2.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %DocumentFonts: CMR10 CMBX12 CMTI10 CMMI10 %EndComments %DVIPSCommandLine: dvips hw
Syracuse - CIS - 252
Homework 4AdministriviaCIS 252 C Introduction to Computer Scienceshould return "msssspp md p".This homework is due in the bin in CST 3-212 by noon on Friday, (e) Define a function disemvowel' which computes the same thing February 15. You may w
Syracuse - CIS - 252
Homework 7: A Start at Higher-Order FunctionsCIS 252Introduction to Computer ScienceA DMINISTRIVIA . This homework is due in the bin in CST 3-212 by noon by white-space characters and which itself contains no white-space charon Monday, March 24
Syracuse - CIS - 252
Lab 10: A Types Scavenger Hunt OverviewThis lab gives you some more practice with types, especially as they relate to functions and function applications. Every valid Haskell expression has some predetermined type as determined by Haskell's typing r
Evansville - CS - 375
CATHWQUIZEXAMMIDFINALLABSPROJSREPORTPARTTOTALGRADEGRADE w/o FINALCWT10030000400080FWT1003002004000100AVG91083000850085B Code169197089000980094A C 21091020
Evansville - CS - 375
CodePR01PR02PR03PR04PR05PR06PR0716911009893100941001002109981001001009710010024059895971009795100293485938010092959239519210097100949503975961009010097100100429787638010094100100585396
Evansville - CS - 375
Code16918791210991952405859129347585395195893975938242976791585382946129949363727784648087977364809076512408302819491737978976696100
Evansville - CS - 375
CodeHW 1HW 2HW3HW4169198.33100901002109100108.33100100240510010090100293466.67100900395183.33108.33900397510010088100429796.67100100100585383.33108.33951006129100100100100637210010095100648096.6
Syracuse - CIS - 252
Homework 10CIS 252 (Spring 2009) - Introduction to Computer ScienceCoverageThis assignment focuses on material in Chapter 18 of Haskell: The Craft of Functional Programming (HCFP).3. HCFP, Exercise 18.5 Hint: Insertion sort (described in the t
Syracuse - CIS - 252
For a constant k: S E k;C D For a variable x: S E x;C D var - a;S E C D , where lookup x E = a b;a;S E pair;C Clo(x,M,E);S abstr - E C D D dopair - (a,b);S E C D const - k;S E C D Dealing with pairs: S E (M,N);C D pair - S E M;N;pair;C DFunction de
Syracuse - CIS - 454
All of the material below was gleaned from "Risks to the Public" by Peter G.Nuemann and contributors. The archives are most easily reached at http:/www.risks.org-Using the technology:England's NHS loses patient data: bad new
Syracuse - CIS - 454
Syracuse - CIS - 500
%!PS-Adobe-2.0 %Creator: dvips(k) 5.78 Copyright 1998 Radical Eye Software (www.radicaleye.com) %Title: syllabus.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %DocumentFonts: CMCSC10 CMR12 CMBX10 CMR10 CMSS10 CMTI10 CMSY10 CMR8 %+ CMR6 C
Syracuse - CIS - 500
%!PS-Adobe-2.0 %Creator: dvips(k) 5.78 Copyright 1998 Radical Eye Software (www.radicaleye.com) %Title: projects.dvi %Pages: 2 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMR10 CMBX12 CMSY10 CMBX10 CMTI10 %EndComments %DVIPSCommandLi
Syracuse - CIS - 500
%!PS-Adobe-2.0 %Creator: dvips(k) 5.78 Copyright 1998 Radical Eye Software (www.radicaleye.com) %Title: hw1.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %DocumentFonts: CMR10 CMBX12 CMTI10 %EndComments %DVIPSCommandLine: dvips hw1 -o %D
Syracuse - CIS - 500
%!PS-Adobe-2.0 %Creator: dvips(k) 5.78 Copyright 1998 Radical Eye Software (www.radicaleye.com) %Title: hw2.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %DocumentFonts: CMR10 CMBX12 CMTI10 CMMI10 CMSY10 CMMI8 %EndComments %DVIPSCommandL
Syracuse - CIS - 500
%!PS-Adobe-2.0 %Creator: dvips(k) 5.78 Copyright 1998 Radical Eye Software (www.radicaleye.com) %Title: hw3.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %DocumentFonts: CMR10 CMBX12 CMTI10 CMR8 CMMI8 CMSY10 CMMI10 CMTT10 %EndComments %D
Syracuse - CIS - 500
%!PS-Adobe-2.0 %Creator: dvips(k) 5.78 Copyright 1998 Radical Eye Software (www.radicaleye.com) %Title: hw4.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %DocumentFonts: CMR10 CMBX12 CMTT10 CMTI10 %EndComments %DVIPSCommandLine: dvips hw
Syracuse - CIS - 500
%!PS-Adobe-2.0 %Creator: dvips(k) 5.78 Copyright 1998 Radical Eye Software (www.radicaleye.com) %Title: hw5.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 596 842 %DocumentFonts: CMR10 CMBX12 CMTI10 CMBX10 %EndComments %DVIPSCommandLine: dvips hw
Syracuse - CIS - 500
%!PS-Adobe-2.0 %Creator: dvips(k) 5.78 Copyright 1998 Radical Eye Software (www.radicaleye.com) %Title: hw6.dvi %Pages: 1 %PageOrder: Ascend %BoundingBox: 0 0 612 792 %DocumentFonts: CMR10 CMBX12 CMTI10 CMMI10 CMSY10 %EndComments %DVIPSCommandLine: d
Syracuse - CIS - 655
MICROPROCESSORT H E I N S I D E R ' S G U I D E T O M I C R O P R O C E S S O R H A R D WA R EREPORTwww.MPRonline.com By Har lan McGhan {11/6/06-01}NIAGARA 2 OPENS THE FLOODGATESNiagara 2 Design Is Closest Thing Yet to a True Server on a Chip
Syracuse - CIS - 655
Sun FireTM T2000 Server Getting Started GuideSun Fire T2000 Server DocumentationYou can view and print the following manuals from the SunTM documentation web site: http:/www.sun.com/documentationSun Fire T2000 Server Product Notes (819-2544) Inf
Syracuse - CIS - 655
UltraSPARCTM User's ManualUltraSPARC-I UltraSPARC-IIJuly 1997Sun Microelectronics 901 San Antonio Road Palo Alto, CA 94303Part No: 802-7220-02 This July 1997 -02 Revision is only available online. The only changes made were to support hypertex
Syracuse - CIS - 655
UltraSPARCTM User's ManualUltraSPARC-I UltraSPARC-IIJuly 1997Sun Microelectronics 901 San Antonio Road Palo Alto, CA 94303Part No: 802-7220-02 This July 1997 -02 Revision is only available online. The only changes made were to support hypertex
Syracuse - CIS - 655
UltraSPARC TM-IIiUser's ManualSun Microelectronics901 San Antonio Road Palo Alto, CA 94303 USA 800 681-8845 http:/www.sun.com/microelectronics Part No.: 805-0087-01Copyright 1997 Sun Microsystems, Inc. All Rights reserved. THE INFORMATION CONT
Syracuse - CIS - 655
The UltraSPARCTM-IIi ProcessorTechnology White Paper 1997, 1998 Sun Microsystems, Inc. All rights reserved. Printed in the United States of America. 901 San Antonio Road, Palo Alto, California 94303 U.S.A The product described in this manual may b
Syracuse - CIS - 655
UltraSPARC III CuUser's ManualVersion 1.0 May 2002Copyright 2002 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, California 94303, U.S.A. All rights reserved. Sun Microsystems, Inc. has intellectual property rights relating to techno
Syracuse - CIS - 655
UltraSPARC IIIi ProcessorUser's ManualVersion 1.0 June 2003Copyright 2003 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved. Sun, Sun Microsystems, the Sun logo, Java, Solaris, Chorus, VIS, O
Syracuse - CIS - 655
The Sun UltraTM 5 and Ultra 10 Workstation ArchitectureTechnical White Paper 1997-2001 Sun Microsystems, Inc. All rights reserved. Printed in the United States of America. 901 San Antonio Road, Palo Alto, California 94303 U.S.A The product describ
Syracuse - CIS - 655
Product ManualBarracuda 7200.11 Serial ATAST31500341AS ST31000333AS ST3640323AS ST3640623AS ST3320613AS ST3320813AS ST3160813AS100507013 Rev. E December 2008Revision historyRevision Date Sheets affected or commentsRev A Rev. B Rev. C Rev.
Syracuse - CIS - 655
Barracuda 7200.7 Serial ATAST3200822AS ST3160827AS ST3160023AS ST3160021AS ST3120827AS ST3120026AS ST3120022AS ST380817AS ST380013AS ST380011AS ST340111AS ST340014ASBarracuda 7200.7 Serial ATAST3200822AS ST3160827AS ST3160023AS ST3160021AS ST3120
Syracuse - CIS - 655
Barracuda 7200.7 and Barracuda 7200.7 PlusBest combination of performance, acoustics and reliabilityThe World's Toughest and Quietest HighPerformance Desktop Drive With RecordSetting Storage Density200, 160, 120, 80 and 40 Gbytes 7,200 RPM Ult
Syracuse - CIS - 655
Cheetah 15K.4Mainstream enterprise disc drive storageThe Best Price/Performance, Lowest Cost of Ownership Disc Drive146, 73, and 36 Gbytes-15K RPM-Ultra320 SCSI, 2 Gbit/sec FC and Serial Attached SCSI (SAS)Key Advantages 30 percent more IOPS a
Syracuse - CIS - 554
Early 7:00 7:01early is earlier than late.Late 23:56 23:57 23:58 23:59 0:00 0:01 0:02 0:03 0:04 0:05late is earlier than early.early and alsoearly: Equalequalearly and late: UnequalunequalNow for adding (non-member function)22
Syracuse - CIS - 554
building an 8 by 8 window.building a 3 by 3 window.windows A 8 by 8 window. A 3 by 3 window.destroying A 3 by 3 window.destroying A 8 by 8 window.
Syracuse - CIS - 554
BarucIn lower case: barucIn upper case: BARUCAre they the same? GG sameEnter choice: 9AT THE TOP
Syracuse - CIS - 554
3 5 4 2 2 6 1 4 1 1 2 6 1 1 6 6 4 4 4 1Now for an octohedron 7 3 8 8 8 7 8 2 3 1 5 2 3 7 4 4 3 6 2 1With a fixed seed. 6 4 2 2 6 6 2 2 5 4 1 1 4 6 1 3 5 4 1 6With a fixed seed. 6 4
Syracuse - CIS - 554
90 8070 6050 40 -100000034567
Syracuse - CIS - 554
enter a file name followed by %: my output file.txt%first letter: mThe string: my output file.txtThe size of st: 18The length of st: 18
Syracuse - CIS - 554
The ordered list as revealed with pointerlist:2 26 37 48 100The list as it is still stored in datalist:100 37 26 48 2
Syracuse - CIS - 554
BAD COPY CONSTRUCTOR AND OPERATOR=Enter age: 3Enter age: 5Enter age: 7JonesMOM:35 DAD: 40The 3 kids: 3 5 7 SmithMOM:35 DAD: 40The 3 kids: 3 5 7 Jones after changeMOM:35 DAD: 40The 3 kids: 18 5 7 Smith with no changeMOM:35 DAD
Syracuse - CIS - 554
INTS BEFORE ORDER:4 2INTS AFTER ORDER:2 4KID BEFORE ORDER:NellieMaxAFTER ORDER:- oops, not legalNellieMaxBoxes before order:40564Boxes in order:64405
Syracuse - CIS - 554
STUDENT: Student constructor.EMPLOYEE: Employee constructor.TA: Student constructor.Employee constructor.TA constructor.18 years old.I am 18.I have a 4.0 GPA.I earn $5 per hour.
Syracuse - CIS - 352
Quiz 3b Practice QuestionsCIS 352: Programming LanguagesQuestion 1 (8 points). Suppose we have the following definitions in the version of our defined language that includes exceptions. define define define define f = proc (n) if zero?(sub1(n) th
Syracuse - CIS - 453
642 531STUDE N T SCHE D U LAR2Colin Ruane Sheldon Thomas Josh StimmelTable of Contents1.1. Int roduction. .pg. 1 1.1.1. Purpose. .pg. 11.1.2. Scope.. .pg. 1 1.1.3. Definitions. .pg. 1 1.1.4. References.. .pg. 1 1.1.5. Overview. .pg. 1 1.2.
Syracuse - CIS - 252
1. (26 points) Suppose that the following definitions are made:import Char lon : [Int] lon = [13, 20, 6, -5] one : Int -> Bool one x = x > 10 & even x two : (Char,Int) -> Bool two (c,i) = isLower c & i > 100 three : Char -> Int -> Int three c i = 2*
Syracuse - CIS - 453
Zombies On The HillThe Ultimate Zombie Experience Brought to you by: Jared Brothers Taylor Johnson Ben Kiemle Scott Shih Mason You1High-Level Design2ClientClientOgre3D RakNet NxOgre (PhysX) QuickGUI OIS OgreAL (OpenAL) LuaBindThe high-lev
Syracuse - CIS - 453
High Level DesignMeera NadeemPedro Urbina December 13, 2007Mark Silverman"A Game of Wits and Aim"Page | 2Table of Contents1. Modules: .. 4 1.1. 1.2. 1.3. 1.4. 2. User Interface: . 4 Physics Engine: .. 5 Graphics Engine: . 6 Game Engine:
Syracuse - CIS - 453
CSE 453: SOFTWARE SPECIFICATION AND DESIGNBull's eye 007A Game of Wits and AimMeera Nadeem Pedro Urbina Mark Silverman 10/24/2007This document provides an overview and the specifications of "Bull's Eye 007," a game of darts.Table of Contents
Syracuse - CIS - 252
Question 1=-=-=-=-=-=Consider the following Turing Machine (written in the Haskell-executableformat from class and the homeworks):myTM : ProgmyTM = [ ("A",'1'),('X',Rght,"B"),("A",'#'),('#',Lft,"D"),("B",'1'),('1',Rght,"B"),("B",'#'),('