CS470 Lab3 TA Notes. Step 1 This is just a simple program that reads in from the command line the time the program should run.

Slides:



Advertisements
Similar presentations
Basic Java Constructs and Data Types – Nuts and Bolts
Advertisements

C Functions. What are they? In general, functions are blocks of code that perform a number of pre-defined commands to accomplish something productive.
1 CS345 Operating Systems Φροντιστήριο Άσκησης 1.
Lecture 20 Arrays and Strings
What is a pointer? First of all, it is a variable, just like other variables you studied So it has type, storage etc. Difference: it can only store the.
Current Assignments Homework 5 will be available tomorrow and is due on Sunday. Arrays and Pointers Project 2 due tonight by midnight. Exam 2 on Monday.
IT253: Computer Organization Lecture 6: Assembly Language and MIPS: Programming Tonga Institute of Higher Education.
Input from STDIN STDIN, standard input, comes from the keyboard. STDIN can also be used with file re-direction from the command line. For instance, if.
Chapter 10.
IAT 800 Lab 1: Loops, Animation, and Simple User Interaction.
Command-line arguments CS 201 Fundamental Structures of Computer Science.
CS470 Lab 4 TA Notes. Objective Simulate the activities of a producer and consumer – Page 326 Use thread synchronization to solve the producer-consumer.
Python November 18, Unit 7. So Far We can get user input We can create variables We can convert values from one type to another using functions We can.
Lab2 TA Notes. Set up for Visual C++ New Workspace Win32 Console Application – This runs from a command line Chose Blank Project Add your.C file Build.
CSE 451 Section 4 Project 2 Design Considerations.
Lecture No: 16. The scanf() function In C programming language, the scanf() function is used to read information from standard input device (keyboard).
CTEC 1863 – Operating Systems Shell Scripting. CTEC F2 Overview How shell works Command line parameters –Shift command Variables –Including.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
INTRO TO PROGRAMMING Chapter 2. M-files While commands can be entered directly to the command window, MATLAB also allows you to put commands in text files.
A Level Computing#BristolMet Session Objectives U2#S6 MUST identify different data types used in programming aka variable types SHOULD describe each data.
CS1550 Assignment 5 Multiprogramming Implementation notes Matt Craven.
CS 470 Lab 5 Comment your code. Description of Lab5 Create Four projects – Driver – Producer – Filter – Consumer.
CNG 140 C Programming (Lecture set 9) Spring Chapter 9 Character Strings.
February 14, 2005 Characters, Strings and the String Class.
Project 1, Command Shell CS-502 (EMC) Fall Programming Project #1 Command Shell CS-502, Operating Systems EMC, Fall 2009 (Slides include materials.
CSC Java Programming, Fall, 2008 Week 2: Java Data Types, Control Constructs, and their C++ counterparts, September 4.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 5 – Dental Payment Application: Introducing.
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
Final Exam Review Closed book Closed laptop One sheet of notes permitted SE-0010 Dr. Mark L. Hornick 1.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
Command Line Arguments plus Variable-Length Arrays Systems Programming.
Introduction to Perl Part III By: Bridget Thomson McInnes 6 Feburary 2004.
Fall 2015CISC124 - Prof. McLeod1 CISC124 Have you filled out the lab section survey? (As of last night 54 left to fill out the survey.) TA names have been.
CPS4200 Unix Systems Programming Chapter 2. Programs, Processes and Threads A program is a prepared sequence of instructions to accomplish a defined task.
1 Flight Times. 2 Problem Specification 3 Additional Specifications You may assume that the input is a valid 24 hour time. Output the time entered by.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
CSE 351 GDB Introduction. Lab 1 Status? How is Lab 1 going? I’ll be available at the end of class to answer questions There are office hours later today.
CS Class 03 Topics  Sequence statements Input Output Assignment  Expressions Read pages Read pages 40 – 49 for next time.
Fall 2002 CS 325 Class Notes Page 1 Lecture 25 Today –exec() in Unix –CreateProcess in Windows Announcements.
1 Basic Java Constructs and Data Types – Nuts and Bolts Looking into Specific Differences and Enhancements in Java compared to C.
CSC141- Introduction to Computer programming Teacher: AHMED MUMTAZ MUSTEHSAN Lecture – 21 Thanks for Lecture Slides:
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Computer Organization and Design Pointers, Arrays and Strings in C Montek Singh Sep 18, 2015 Lab 5 supplement.
Process Management Azzam Mourad COEN 346.
1 Lecture07: Memory Model 5/2/2012 Slides modified from Yin Lou, Cornell CS2022: Introduction to C.
Chapter 15 Strings as Character Arrays
Characters and Strings
1 Pointers: Parameter Passing and Return. 2 Passing Pointers to a Function Pointers are often passed to a function as arguments  Allows data items within.
Announcements You will receive your scores back for Assignment 2 this week. You will have an opportunity to correct your code and resubmit it for partial.
1 CSE 451 Section 2: Processes, the shell, and system calls.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
CS113 Introduction to C Instructor: Ioannis A. Vetsikas Lecture 5 : September 4.
1 Homework Continue with K&R Chapter 5 –Skipping sections for now –Not covering section 5.12 Continue on HW5.
Principles of Programming - NI Chapter 10: Character & String : In this chapter, you’ll learn about; Fundamentals of Strings and Characters The difference.
C++ Functions A bit of review (things we’ve covered so far)
1. Advanced SQL Functions Procedural Constructs Triggers.
Object Oriented Programming Lecture 2: BallWorld.
Discussion on mp1.
Stack and Heap Memory Stack resident variables include:
Command Line Arguments
CH5 TCP Client - Server Example:
Administrative things
Files I/O, Streams, I/O Redirection, Reading with fscanf
C Stuff CS 2308.
Encryption and Decryption
Programming Project #1 Command Shell
Lab 4: Introduction to Scripting
ENERGY 211 / CME 211 Lecture 29 December 3, 2008.
Presentation transcript:

CS470 Lab3 TA Notes

Step 1 This is just a simple program that reads in from the command line the time the program should run.

Step 2 Do not create a new program Modify the program from Step 1 Each new background process should be opened in its own console Use the sample background program in the book on page 249 to create the background programs

Step 2 cont. Each background program should allow the user to terminate it. Ensure that handles of all processes and handle are closed at the end of the program

Step 3 Again do not create a new program Modify the program from Step 2 Use a waitable timer to terminate all processes if not terminated by the user You will either need to write a function to convert user time given into machine time or read about quitTime and Quadpart in the MSDN library

Lab Environment

For all labs use #define _WIN32_WINNT 0x0500 at the top of your code somewhere instead of where the book says to add /D _WIN32_WINNT=0x400 as a compiler flag.

New notes 2006: Lab 3 Part A Usage example: U:\>lab3a The integer represents the time the program waits. Pseudo-code: main : args make sure there are 2 arguments, one of which is an integer that is greater than -1 create a waitable timer, assigning it to a handle set the timer wait for timer to complete clean up handle exit Remarks: The book uses weird code to set LARGE_INTEGER quitTime. Use quitTimer.QuadPart = * atoi( argv[ 1 ] ); Then pass quitTimer to SetWaitableTimer like how it is in the book.

New notes 2006: Lab 3 Part B Usage example: U:\>lab3b The integer represents the number of processes it should spawn. Pseudo-code: main : args make sure there are 2 arguments, one of which is an integer that is greater than -1 for integer from command line create a process that spawns an external program exit Remarks: It is advisable to use the program from part A and modify it a bit as the external program that part B spawns as it essentially does what you need.

New notes 2006: Lab 3 Part B To pass a command line string to CreateProcess, set up a char array as the program name and a space. Then use strcat and itoa to append a number if need be. Remember to always Zeromemory() and related before CreateProcess() if you're reusing the startupInfo variable.

New notes 2006: Lab 3 Part C Usage example: U:\>lab3c Integer1 - The number of seconds you want the controlling process to run for. Integer2 - The number of processes to spawn. Pseudo-code: main : args make sure there are 3 arguments, the last two being integers that are greater than -1 for the first command line integer create a process that spawns an external program add the process to a handle table create a waitable timer set the timer wait for the timer to expire for each handle in handle table terminate process associated with the handle clean up handles

New notes 2006: Lab 3 Part C Remarks: The for loop for creating processes should look nearly similar to the one in part B. The setting up and waiting of the waitable timer should look nearly similar to the one in part A. To kill processes, you need an array of handles. In the for loop that creates the process you notice that you're passing a reference to processInfo. While in the loop, processInfo.hProcess is the handle associated with the process you create. Add that the handle array. Then in the loop where you kill processes you can use TerminateProcess as it's found in the book. Remember to always Zeromemory() and related before CreateProcess() if you're reusing the startupInfo variable. TA if you have questions. Always try to explain the problem as thoroughly as possible. Attach code. Refer to the code and line numbers in your .