CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts...

36
CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos

Transcript of CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts...

Page 1: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

CS 350Operating Systems

&Programming Languages

Ethan RaceOren Rasekh

Christopher RobertsChristopher Rogers

Anthony SimonBenjamin Ramos

Page 2: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Benjamin Ramos

Introduction to Programming

Languages

Page 3: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Programming Languages

According to Wikipedia, a programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely

For us computer science students, it is the lifeblood of all the programs, homework assignments and projects that we do during our time here in Binghamton University

Page 4: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Languages that contain librariesLanguages that are object-oriented

based

We have dealt with many Programming Languages

Page 5: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

We have also dealt with many functions, libraries and methods

The C Specials

• free()

• malloc()

• printf()

With Java, you get• The scanner library• System.out.print.ln()

With C++, you get introduced to numerous libraries, like the STL Library and the POSIX Library.

WRPDRV() ?

Page 6: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

The question to ask though is?

How does a specific programming language communicate with the operating system in order to

achieve what the programmer wants in their program?

How does the operating system interpret and compile the libraries, functions and methods of a

specific programming language so that we have a working program?

How can we as a programmer make our program so that it can run efficiently in the operating system?

Page 7: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

What we will discuss in this presentation

• How to wisely use the Operating systems memory in our programs? - Memory Management

• How to transfer a piece of code from one language to another? - Portability

• How do you run multiple programs or processes at the same time? - Multiprogramming

• What Tools are needed in the execution of a language on a given OS? - Compilers.

• The idea about OS Libraries, Security through System calls and there Reusability - Libraries, API's & System Calls

Page 8: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Memory Management

How to Overclock a Positronic Brain

Ethan Race

Page 9: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

In most Modern Languages:

AutomaticComputer Managed Memory

&ManualHuman managed Memory

Types of Memory Management

Page 10: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

• Faster, and more Efficient

• Makes the programmer's job easier

• BUT

• You take a performance hit

• Might keep memory that is reachable, but never used again

Automatic Memory Management

Page 11: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

• The memory is managed by the Computer.o As part of the language, or an extension thereof

• One form is Garbage Collectingo First in LISP in 1959o Required by C#, Java and most scripting

languages.o Allowed in C++, ADA, along with manual

managemento Can be turned off in D

Automatic Memory Management (Cont.)

Page 12: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

• The programmer decides when memory is freed (free, delete, etc.).

• Available in C/C++, ADA, etc.

• Performance is increased

• The programmer knows what is going on.

• BUT

• The programmer has more to keep track of

• There are generally more errors.o Pointer errors, and memory leaks

Manual Memory Management

Page 13: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

• Automatico Managed by Computero Easier to program

• Manualo Managed by Programmero More performance

Memory Management (Summary)

Page 14: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Oren Rasekh

Portability

Page 15: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Portability

• What is it?

• How can we achieve it?

• Do we want it?

Page 16: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

What is portability?

• Dictionary.com:

• Capable of being transported or conveyed

• Can move from platform to platform

• Must be efficient

• Little to no change in code

Page 17: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Where is portability?

• GNU Compiler Collection

• Java

• Posix Standards

• X Window System

Page 18: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Things to consider

• System specific functionso sleep vs. Sleep

• System word sizeo compile to 32 bit | 64 bit

• sizeofo int * pointer = malloc(sizeof(int) * 10);

Page 19: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

How can we be portable?

JAVA

Page 20: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

How can we be portable?

Posix Standards

• Portable Operating System Interface

• Standards for cross platform portability

• Prevent system dependency issues

Page 21: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Do we want it?

Cons

• Speed decrease

• Higher level of abstraction

• Learning curve

• Implementation time

Pros• Write code once• Easier to maintain• Cost

I DON'T KNOW (but probably)

Page 22: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Christopher Roberts

Multiprogramming

Page 23: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Multiprogramming

1. What is it?

2. How can we do it?a) Processesb) Threads

3. What does the OS need?a) Schedulingb) Memory Management

4. Challenges and Benefits

Page 24: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

What Is Multiprogramming?

• Definition:o Multiple programs running at the

same time

• What is involved:o Space multiplexingo Time multiplexing

Page 25: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Processes and Threads

• Processo a program and its address space

• Threado a unit of work

• Need to be managed efficiently

Page 26: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Multiprogramming and the Operating System

• Memoryo OS must set up Process Control Block

and Thread Control Block

o Must provide memory protection

o Memory swapping Allows the OS to provide more

memory than is physically available

Page 27: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Multiprogramming and the Operating System

• Schedulingo Determine which program/process/thread runs

nexto Keep track of state of process

Ready Running Waiting

o Two basic types of schedulers Non-preemptive - batch systems

• Priority Preemptive - modern systems

• Round Robin

Page 28: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Benefits and Challenges

• Challengeso Protecting critical sections (threads)o Debuggingo Using "safe" functions

• Benefitso Can fully utilize powerful

processorso Performance increase

Page 29: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Christopher Rogers

Compilers

Page 30: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

• What is a compiler?

• Several types:o Native Compilero Cross-compilero Decompilero Language Translator

• Responsible for performing various tasks:o Lexical analysis, Semantic analysis,

Preprocessing, parsing, and code generation and optimization.

• Environment for compiler and program

Compilers

Page 31: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

• Executable is platform independent.

• Used in:o Embedded Systemso Microcontrollerso Multiple systems

• Utilized when arch or OS differs.

• GCC can be configured to cross compile.

Cross-Compilers

Page 32: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

• Platform dependence

• Windows:o Visual Basico Microsoft Visual C#o IAR C/C++ Compilers (Proprietary)

• Unix:o Gambas (Basic)o HP aC++ (C++)o TenDRA (C++)

• Both:o GCC (C/C++)o Multi (C++)

Compilers and the OS

Page 33: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

Anthony Simon

Libs, API's & System Calls

Page 34: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

An API or Library offers a reusable and standard interface to a programming

package

What does this mean for a programming language??

Reusability

Page 35: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

System Calls are API's that provide

"secure" execution environments

So What??

Security

Page 36: CS 350 Operating Systems & Programming Languages Ethan Race Oren Rasekh Christopher Roberts Christopher Rogers Anthony Simon Benjamin Ramos.

The End