cs 350 operating systems & programming languages group: victor yevtukh, kyle tassey, ankit...

31
CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Upload: bryan-campbell

Post on 28-Dec-2015

219 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

CS 350Operating Systems

& Programming Languages

Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Page 2: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Operating Systems & Programming Languages

Memory Management 

Most of todays Programming langauges use • Automatic memory management• Manual memory management 

 BASIC, Erlang, Haskell, JavaTM, JavaScriptTM, Lisp Perl,          Prolog, Python, Scheme, Smalltalk, etc. [1]

[1] http://www.memorymanagement.org/articles/begin.html

Page 3: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

• Manual Memory ManagementManual memory management is where the programmer has direct control over when memory may be recycled. 

http://www.memorymanagement.org/articles/begin.html

Advantages•  Easier for programmer to

understand/program•  Performance gains

Disadvantages•  Overload on the programmer (More repetative

code used for bookeeping of memory)• More bugs

Page 4: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Automic Memory ManagementAutomatic memory management is a service, either as a part of the language or as an extension, that automatically recycles memory that a program would not otherwise use again

Advantages•  Memory management is typically faster•  More efficient•  The programmer is free from the problem

Disadvantages•  Memory may be retained because it is

reachable, but won't be used again;• Automatic memory managers (currently) have

limited availability

Page 5: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Some Problems

• Dangling pointerso This is usually confined to manual memory management

• Memory Leako  Some programs continually allocate memory without ever giving

it up and eventually run out of memory.

• Poor locality of referenceo  Another problem with the layout of allocated blocks comes

from the way that modern hardware and operating system memory managers handle memory: successive memory accesses are faster if they are to nearby memory locations. If the memory manager places far apart the blocks a program will use together, then this will cause performance problems.

Page 6: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

•// "Give me 3 bytes of memory."void* pMy3BytesMemory = malloc( 3 );

•// "Here are your 3 bytes of memory."free( pMy3BytesMemory )

•Possible Errors/Problems•-Memory Leaks•-Buffer Overuns•-Program Crashes

Example of a Flat memory Model Problem

Page 7: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Multiprocessing

• All programming languages make use of multiprocessing

• Allows multiple programs to run simultaneously

• Without it, programs would have to run one at a time

Page 8: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Multiprocessing

• Scheduling Prioritieso high priority = most processor timeo low priority = least processor timeo maximum efficiencyo least downtime

Page 9: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Multiprocessing

• Avoid unproductive processingo wastes resourceso busy waiting, timing loops, etco halt execution of a process not doing worko most programming languages make use of

monitors or semaphores to accomplish this signal when a process can run again

Page 10: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Multiprocessing

• Cacheo Many processes need resources from main

memoryo Limited space in cache

but you want maximum cache hitso The competition for cache space means the OS

must help decide which processes receive cache space to minimize cache misses

Page 11: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Application Programming Interface

• The Operating System provides an API to programmers so that they can write applications consistent with the operating environment[1]

• The API acts as building blocks that the programmers assemble into applications  

•  Windows, Linux, and Mac all have different APIs

[1]http://www.washington.edu/accessit/articles?15

Page 12: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Libraries

• A library is a collection of resources used in the development of software

• Some libraries are system-specific (Standard Template Libraries).  A few system-specific libraries:o <Windows.h> is specific to Windowso <sys/types.h> is specific to Linuxo <sys/time.h> is specific to Linux

Page 13: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

System Calls

• Applications make system calls to request information from the operating system

• System calls made by Programming Languages include read, write, open, close, etc.

• strace is a Linux command that can be used to show the system calls of a program

Page 14: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

strace for Hello World Program

Page 15: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

stracecont.

Page 16: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

I/O

• Handled by Operating System• Keyboard and other input devices• System Call to Operating System• Allows Portability of code

Page 17: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

DIFFERENT OPERATING SYSTEMS

Three major Operating Systems• Macantosh• Windows• Linux

Page 18: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Differences

-Most programming languages now are very friendly and can run on different operating systems. 

-operating system are designed differently so the programming language needs to know which operating system is running because for example, default windows threads are different from the posix threads.

Page 19: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Differences

- Almost all the drivers for USB, Printing, FUSE and Graphics for Linux are in the user space where as in Windows they operate in the kernel space. And as Andy Tanenbaum put it, it is better if more and more drivers run in the user space than the kernel space as this makes the OS more reliable and secure- Linux kernel has inbuilt support for the most variety of file systems.-Both Linux and Windows kernels are developed using C and assembly language but apart from that Windows also has a significant percentage of C++ code.

Page 20: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

continued..

- Linux kernel boots on diverse hardware architecture (around 22) including some game stations such as Sony Playstation. Where as Windows support only a measly 3 architectures.- Not surprisingly, the kernel size ofLinux is just over half of that of Windows.

Page 21: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Programming Languages

• A programming language is an artificial language designed to express computations that can be performed by a machine, particularly a computer.

Page 22: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

First Programming Languages

• The earliest programming languages predate the invention of the computer, and were used to direct the behavior of machines such as Jacquard looms and player pianos

Page 23: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Syntax and Semantics

• A Programming Language has two components

• Syntax - he set of rules that define the combinations of symbols that are considered to be correctly structured programs in that language.

• Semantics - the meaning of language

Page 24: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Design

• Languages are either designed from scratch or a combination of existing languages to meet new needs in programming

• There is currently no universal language that serves all purposes because of the diversity of contexts languages are used in.

• Languages can differ by speed, size, simplicity, reuse, and personal tastes of programmers

Page 25: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Implementation

• The implementation of a programming language provides a way to execute that program on one or more configurations of hardware and software.

• Two approaches to programming language implementation

• Compilation: C/C++, Basic, Haskell, Ada• Interpretation: Perl, Python, MATLAB, Ruby, Pascal,

and Java

Page 26: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Portability Yuan Xu

• What is Portability?• Run a program on different machines • Works like:

RecompilingMaking small changes to the source code.

Page 27: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

C Portability

• Core CExtremely portable

• GNU C compiler,  • Standard I/O library

Mathematics routinesInternationalization

Page 28: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

                    Java Portability

•“write once, run everywhere”.

Page 29: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

Avoiding System Dependencies

• Location of key system files and directories• Mail spools directory

/var/spool/mail         or         /var/mail.• Local directory name.

Avoid absolute directory name!• Avoid dependence on the size of a pointer or

reference being the same size as a particular integral type.assert(int.sizeof == (int*).sizeof);

• Minimum integral and floating type sizes

Page 30: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

32 to 64 Bit Portability

• Int bits32 bits     ==>     64 bits

•Pointers & object references4 bytes    ==>     8bytes

•Use size_t

Page 31: CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu

  

 Thank you ALL!