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

Post on 26-Dec-2015

219 views 0 download

Tags:

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

CS 350Operating Systems

&Programming Languages

Ethan RaceOren Rasekh

Christopher RobertsChristopher Rogers

Anthony SimonBenjamin Ramos

Benjamin Ramos

Introduction to Programming

Languages

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

Languages that contain librariesLanguages that are object-oriented

based

We have dealt with many Programming Languages

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() ?

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?

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

Memory Management

How to Overclock a Positronic Brain

Ethan Race

In most Modern Languages:

AutomaticComputer Managed Memory

&ManualHuman managed Memory

Types of Memory Management

• 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

• 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.)

• 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

• Automatico Managed by Computero Easier to program

• Manualo Managed by Programmero More performance

Memory Management (Summary)

Oren Rasekh

Portability

Portability

• What is it?

• How can we achieve it?

• Do we want it?

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

Where is portability?

• GNU Compiler Collection

• Java

• Posix Standards

• X Window System

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);

How can we be portable?

JAVA

How can we be portable?

Posix Standards

• Portable Operating System Interface

• Standards for cross platform portability

• Prevent system dependency issues

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)

Christopher Roberts

Multiprogramming

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

What Is Multiprogramming?

• Definition:o Multiple programs running at the

same time

• What is involved:o Space multiplexingo Time multiplexing

Processes and Threads

• Processo a program and its address space

• Threado a unit of work

• Need to be managed efficiently

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

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

Benefits and Challenges

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

• Benefitso Can fully utilize powerful

processorso Performance increase

Christopher Rogers

Compilers

• 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

• 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

• 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

Anthony Simon

Libs, API's & System Calls

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

package

What does this mean for a programming language??

Reusability

System Calls are API's that provide

"secure" execution environments

So What??

Security

The End