Download presentation
Presentation is loading. Please wait.
Published byBryan Campbell Modified over 9 years ago
1
CS 350 Operating Systems & Programming Languages Group: Victor Yevtukh, Kyle Tassey, Ankit Tamakuala, Matt Wetzel, David Yeager, Michael Wang, Yuan Xu
2
Operating Systems & Programming Languages Memory Management Most of todays Programming langauges use Automatic memory management Manual memory management BASIC, Erlang, Haskell, Java TM, JavaScript TM, Lisp Perl, Prolog, Python, Scheme, Smalltalk, etc. [1]BASICJavaJavaScriptLispPerlPrologSchemeSmalltalk [1] http://www.memorymanagement.org/articles/begin.html
3
Manual Memory Managemen t Manual 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
4
Automic Memory Management Automatic 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
5
Some Problems Dangling pointers o This is usually confined to manual memory management Memory Leak o Some programs continually allocate memory without ever giving it up and eventually run out of memory. Poor locality of reference o 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.
6
// "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
7
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
8
Multiprocessing Scheduling Priorities o high priority = most processor time o low priority = least processor time o maximum efficiency o least downtime
9
Multiprocessing Avoid unproductive processing o wastes resources o busy waiting, timing loops, etc o halt execution of a process not doing work o most programming languages make use of monitors or semaphores to accomplish this signal when a process can run again
10
Multiprocessing Cache o Many processes need resources from main memory o Limited space in cache but you want maximum cache hits o The competition for cache space means the OS must help decide which processes receive cache space to minimize cache misses
11
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
12
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 is specific to Windows o is specific to Linux
13
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
14
strace for Hello World Program
15
strace cont.
16
I/O Handled by Operating System Keyboard and other input devices System Call to Operating System Allows Portability of code
17
DIFFERENT OPERATING SYSTEMS Three major Operating Systems Macantosh Windows Linux
18
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.
19
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.
20
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.
21
Programming Languages A programming language is an artificial language designed to express computations that can be performed by a machine, particularly a computer.
22
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
23
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
24
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
25
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
26
Portability Yuan Xu What is Portability? Run a program on different machines Works like: Recompiling Making small changes to the source code.
27
C Portability Core C Extremely portable GNU C compiler, Standard I/O library Mathematics routines Internationalization
28
Java Portability “write once, run everywhere”.
29
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
30
32 to 64 Bit Portability Int bits 32 bits ==> 64 bits Pointers & object references 4 bytes ==> 8bytes Use size_t
31
Thank you ALL!
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.