Presentation is loading. Please wait.

Presentation is loading. Please wait.

An Introduction to Linux

Similar presentations


Presentation on theme: "An Introduction to Linux"— Presentation transcript:

1 An Introduction to Linux
COS 151 An Introduction to Linux

2 Lesson Outcome An overview of Linux OS
Concept of Boolean Expressions (…If/else statement) Concept of … Flow diagram Introduction to Algorithm (Next week lectures)

3 Content What is Linux Linux Kernel Map Examples Operating System
Linux versus Microsoft Windows Linux Kernel Map Examples While loop If and else statements

4 What is Linux? It’s an Operating System Linux vs. Microsoft Windows
Operating systems graphic source:

5 Linux Kernel Map The kernel is the central nervous system of Linux, include OS code which runs the whole computer. It provides resources to all other programs that you run under Linux, and manages all other programs as they run. The kernel includes the code that performs certain specialized tasks, including TCP/IP networking. The kernel design is modular, so that the actual OS code is very small to be able to load when it needs, and then free the memory afterwards, thus the kernel remains small and fast and highly extensible

6 Examples If and else statements While loop

7 Questions?

8 If and else statement

9 Boolean Expressions More complex Boolean expressions are also possible
Operator Meaning == equal to != not equal to < less than <= less than or equal to > greater than >= greater than or equal to More complex Boolean expressions are also possible

10 Then if Statement The Java if statement has the following syntax: if (boolean-condition) statement; If the Boolean condition is true, the statement is executed; if it is false, the statement is skipped This provides basic decision making capabilities

11 If statement flow diagram

12

13

14

15 If .. Else Statement An else clause can be added to an if statement to make it an if-else statement: if (condition) statement1; else statement2; If the condition is true, statement1 is executed; if the condition is false, statement2 is executed

16 If/else flow diagram

17 Lets work on this example together 
An algorithm for inter-library lending of materials Input: The unique code of the user (userID) Output: Message on whether the material was successfully loaned or not Algorithm: 1. Set numMaterialsLoaned to 0 2. For each material (materialID) loaned to user userID: 2.1 Check availability of materialID 2.2 If not available then 2.2.1 Print message “loan unsuccessful – material is not available” 2.3 Else 2.3.1 If materialID is reserved by another user then Print message “loan unsuccessful – material is reserved” 2.3.2 Else Print message “loan successful – material is loaned” Update arrival date in database (today’s date + 15 days) Add 1 to numMaterialsLoaned 3. Print message: “Number of materials loaned:” numMaterialsLoaned 4. Quit

18 While statement

19 The while statement A while statement has the following syntax: while (condition) statement; If the condition is true, the statement is executed; then the condition is evaluated again The statement is executed over and over until the condition becomes false If the condition of a while statement is false initially, the statement is never executed Therefore, we say that a while statement executes zero or more times The while statement

20 While statement flow diagram

21

22 Questions?


Download ppt "An Introduction to Linux"

Similar presentations


Ads by Google