Presentation is loading. Please wait.

Presentation is loading. Please wait.

CMSC 104, Section 301, Fall 20021 Lecture 04, 9/11/02 Operating Systems and Using Linux Review Operating System. Linux Overview. Frequently Used Linux.

Similar presentations


Presentation on theme: "CMSC 104, Section 301, Fall 20021 Lecture 04, 9/11/02 Operating Systems and Using Linux Review Operating System. Linux Overview. Frequently Used Linux."— Presentation transcript:

1 CMSC 104, Section 301, Fall 20021 Lecture 04, 9/11/02 Operating Systems and Using Linux Review Operating System. Linux Overview. Frequently Used Linux Commands. Definition of an Algorithm. Algorithm Examples.

2 CMSC 104, Section 301, Fall 20022 Lecture 04, 9/11/02 Review Operating System A computer program. Performs many operations, such as: Allows you to communicate with the computer (tell it what to do). Controls access (login) to the computer. Keeps track of all processes currently running. At this point, your main concern is how to communicate with the computer using the OS.

3 CMSC 104, Section 301, Fall 20023 Lecture 04, 9/11/02 Connecting to UMBC Linux Servers See http://www.umbc.edu/oit/pc_ppp/index.html for dtails.http://www.umbc.edu/oit/pc_ppp/index.html Setup your PC for dial-up connections. Dial 410-719-1094 or 301-322-6199 with your myUMBC or gl account. (Helpdesk: 410-455-3838 or ECS 020). Telnet to one of the following linux servers: telnet linux1.gl.umbc.edu telnet linux2.gl.umbc.edu telnet linux3.gl.umbc.edu

4 CMSC 104, Section 301, Fall 20024 Lecture 04, 9/11/02 Connecting to UMBC Linux Servers

5 CMSC 104, Section 301, Fall 20025 Lecture 04, 9/11/02 Connecting to UMBC Linux Servers

6 CMSC 104, Section 301, Fall 20026 Lecture 04, 9/11/02 Connecting to UMBC Linux Servers

7 CMSC 104, Section 301, Fall 20027 Lecture 04, 9/11/02 How Do I Communicate With the Computer Using the OS? (con’t) When you log in to the Linux system here, a user prompt will be displayed: linux#[1]% _ where # is the number of the Linux server that you have connected to. You may use any of the Linux servers. The number in the brackets will change as you work. It is the “number” of the command that you are about to type. If this prompt is not on the screen at any time, you are not communicating with the OS.

8 CMSC 104, Section 301, Fall 20028 Lecture 04, 9/11/02 Linux Overview Files and Filenames. Directories and Subdirectories. Frequently Used Commands.

9 CMSC 104, Section 301, Fall 20029 Lecture 04, 9/11/02 Files A file is a sequence of bytes. It can be created by o a text editor (xemacs or pico), o a computer program (such as a C program). It may contain a program, data, a document, or other information. Files that contain other files are called directories (sometimes called folders).

10 CMSC 104, Section 301, Fall 200210 Lecture 04, 9/11/02 Linux Filenames Restrictions o May not contain blanks or other reserved characters. o Have a maximum length. o Are case sensitive. It is best to stick with filenames that contain letters (uppercase or lowercase), numbers, and the underscore ( _ ) for now.

11 CMSC 104, Section 301, Fall 200211 Lecture 04, 9/11/02 Directories Directories contain files or other directories called subdirectories. They may also be empty. Directories are organized in a hierarchical fashion. They help us to keep our files organized.

12 CMSC 104, Section 301, Fall 200212 Lecture 04, 9/11/02 Directories (con’t) /afs/umbc.edu/users/j/d/jdoe28 junk recipes cmsc104 piescookies projects lectures apple peach choc_chip

13 CMSC 104, Section 301, Fall 200213 Lecture 04, 9/11/02 Directories (con’t) Your home directory is where you are located when you log in (e.g., /afs/umbc.edu/users/j/d/jdoe28 ). The current directory is where you are located at any time while you are using the system. Files within the same directory must be given unique names. Paths allow us to give the same name to different files located in different directories. Each running program has a current directory and all filenames are implicitly assumed to start with the name of that directory unless they begin with a slash.

14 CMSC 104, Section 301, Fall 200214 Lecture 04, 9/11/02 Moving in the Directory Tree. (dot) is the current directory... (dot-dot) is the parent directory. Use the Linux command cd to change directories. o Use dot-dot to move up the tree, e.g., cd.. o Use the directory name to move down, e.g., cd cmsc104. o Use the complete directory name (path name) to move anywhere, e.g., cd cmsc104/proj1.

15 CMSC 104, Section 301, Fall 200215 Lecture 04, 9/11/02 Wildcard Characters You will find wildcard characters useful when manipulating files (e.g., listing or moving them). The wildcard characters are * and ?. ? is used to represent any single character. * is used to represent 0 or more characters.

16 CMSC 104, Section 301, Fall 200216 Lecture 04, 9/11/02 Frequently Used Linux Commands pwd – present working directory to check where you are in the directory tree. ls – list of files or subdirectories, e.g., ls proj* or ls –l. cd – change directory to pathname, cd pathname. cp – copy files from file1 to file1b, e.g., cp file1 file1b. mv – rename file from file1 to file2, e.g., mv file1 file2. rm – remove (delete) files, e.g., file1 file2 … mkdir – make directory dir-name, e.g. mkdir dir-name. rmdir – remove (delete) directory, e.g. rmdir dir-name. man – look up how to use the command, man cp. passwd – to change password. ctl-c – to terminate command, process, … Other commands: cat, more.

17 CMSC 104, Section 301, Fall 200217 Lecture 04, 9/11/02 Frequently Used Linux Commands References: Linux man page. Links from the cmsc 104 homepage. http://www.cs.umbc.edu/courses/undergraduate/104/fall02/chen/ Books and the Internet.

18 CMSC 104, Section 301, Fall 200218 Lecture 04, 9/11/02 Examples For example, o make a subdirectory for cmsc104, e.g., –mkdir cmsc104, cd cmsc104, and –make subdirectories for projects, lectures, homeworks, exams, e.g., mkdir projects homeworks exams lectures. o Directory tree: cmsc104 exams homeworks lectures projects ex1 ex2 final hw1 … hwn L1 … Ln proj1 … projn

19 CMSC 104, Section 301, Fall 200219 Lecture 04, 9/11/02

20 CMSC 104, Section 301, Fall 200220 Lecture 04, 9/11/02

21 CMSC 104, Section 301, Fall 200221 Lecture 04, 9/11/02

22 CMSC 104, Section 301, Fall 200222 Lecture 04, 9/11/02 linux1[3]% ls -l drwxr-xr-x 2 lichen 32 2048 Sep 9 15:49 Desktop lrwxr-xr-x 1 lichen 32 7 Sep 2 00:38 Mail ->../Mail drwxr-xr-x 2 lichen 32 2048 Aug 13 1998 bin drwx------ 3 lichen 32 2048 Sep 10 15:25 li lrwxr-xr-x 1 lichen 32 10 Sep 2 00:38 www ->../pub/www access # links owner group file size last modified date filename r: read w: write x: execute l: link d: directory

23 CMSC 104, Section 301, Fall 200223 Lecture 04, 9/11/02 Algorithms, Part 1 of 3 Topics Definition of an Algorithm. Algorithm Examples. Syntax versus Semantics. Reading Sections 3.1 - 3.3

24 CMSC 104, Section 301, Fall 200224 Lecture 04, 9/11/02 Problem Solving Problem solving is the process of transforming the description of a problem into the solution of that problem. We use our knowledge of the problem domain. We rely on our ability to select and use appropriate problem-solving strategies, techniques, and tools.

25 CMSC 104, Section 301, Fall 200225 Lecture 04, 9/11/02 Algorithms An algorithm is a step by step solution to a problem. Why bother writing an algorithm? o For your own use in the future. You won’t have to rethink the problem. o So others can use it, even if they know very little about the principles behind how the solution was derived.

26 CMSC 104, Section 301, Fall 200226 Lecture 04, 9/11/02 Examples of Algorithms Washing machine instructions. Washing hair instructions (ambiguous algorithm). A classic: finding the greatest common divisor (GCD) using Euclid’s Algorithm.

27 CMSC 104, Section 301, Fall 200227 Lecture 04, 9/11/02 Washing Machine Instructions Separate clothes into white clothes and colored clothes. If white clothes: o Set water temperature knob to HOT. o Place white laundry in tub. If colored clothes: o Set water temperature knob to COLD. o Place colored laundry in tub. Add 1 cup of laundry detergent to tub. Close lid and press the start button.

28 CMSC 104, Section 301, Fall 200228 Lecture 04, 9/11/02 Washing Machine Instructions (con’t) Observe that There are a finite number of steps. We are capable of doing each of the instructions. When we have followed all of the steps, the washing machine will wash the clothes and then will stop.

29 CMSC 104, Section 301, Fall 200229 Lecture 04, 9/11/02 Refinement of Algorithm Definition Our old definition: o An algorithm is a step by step solution to a problem. Adding our observations: o An algorithm is a finite set of executable instructions that directs a terminating activity.

30 CMSC 104, Section 301, Fall 200230 Lecture 04, 9/11/02 Ambiguous Algorithms Washing Hair Instructions: 1. Lather. 2. Rinse. 3. Repeat. How could these instructions be hard to follow?

31 CMSC 104, Section 301, Fall 200231 Lecture 04, 9/11/02 Final Version of the Algorithm Definition Our old definition: o An algorithm is a finite set of executable instructions that directs a terminating activity. Final version: o An algorithm is a finite set of unambiguous, executable instructions that directs a terminating activity.

32 CMSC 104, Section 301, Fall 200232 Lecture 04, 9/11/02 History of Algorithms The study of algorithms began as a subject in mathematics. The search for algorithms was a significant activity of early mathematicians. Goal: To find a single set of instructions that can be used to solve any problem of a particular type (a general solution).

33 CMSC 104, Section 301, Fall 200233 Lecture 04, 9/11/02 Euclid’s Algorithm Problem: Find the largest positive integer that divides evenly into two given positive integers, i.e., the Greatest Common Divisor (GCD). Algorithm: 1. Let M, N be two positive integers, where M > N. 2. Divide M by N and call the remainder R. 3. If R is not 0, then Let M = N, N=R. Go to step 2. 4. Else (R = 0) GCD = N.

34 CMSC 104, Section 301, Fall 200234 Lecture 04, 9/11/02 Finding the GCD of 24 and 9 MN R 249 6 9 6 3 63 0 Done. So, 3 is the GCD of 24 and 9.

35 CMSC 104, Section 301, Fall 200235 Lecture 04, 9/11/02 Euclid’s Algorithm (con’t) Do we need to know the theory that Euclid used to come up with this algorithm in order to use it? What intelligence is required to find the GCD using this algorithm?

36 CMSC 104, Section 301, Fall 200236 Lecture 04, 9/11/02 The Idea Behind Algorithms Once an algorithm behind a task has been discovered. o We don't need to understand the principles. o The intelligence is "encoded into the algorithm.“ o The task is reduced to following the instructions.

37 CMSC 104, Section 301, Fall 200237 Lecture 04, 9/11/02 Algorithm Representation Syntax and Semantics o Syntax refers to the representation itself. o Semantics refers to the concept represented (i.e., the logic).

38 CMSC 104, Section 301, Fall 200238 Lecture 04, 9/11/02 Contrasting Syntax and Semantics In the English language, we have both syntax and semantics. Syntax is the grammar of the language. Semantics is the meaning. Given the following sentence, I walked to the corner grocery store. o Is this sentence syntactically correct? o Is it semantically correct?

39 CMSC 104, Section 301, Fall 200239 Lecture 04, 9/11/02 Contrasting Syntax and Semantics (con’t) Given the following sentence, I talked to the funny grocery store. o Is this sentence syntactically correct? o Is it semantically correct? How about I grocery store walked corner the to.

40 CMSC 104, Section 301, Fall 200240 Lecture 04, 9/11/02 Contrasting Syntax and Semantics (con’t) Conclusion: An English sentence may be syntactically correct, yet semantically incorrect. This is also true of algorithms. And it is also true of computer code. Note that it only makes sense to consider semantic if syntax is correct.

41 CMSC 104, Section 301, Fall 200241 Lecture 04, 9/11/02 Next More problem solving and algorithms. Pseudocode. Assignment: o Read 3.1 – 3.10 (skip the C code, just the pseudocode.) o Login to one of the linux servers, perform some of the unix commands from home or school. –linux1.gl.umbc.edu –linux2.gl.umbc.edu –linux3.gl.umbc.edu


Download ppt "CMSC 104, Section 301, Fall 20021 Lecture 04, 9/11/02 Operating Systems and Using Linux Review Operating System. Linux Overview. Frequently Used Linux."

Similar presentations


Ads by Google