You are on page 1of 15

Operating Systems

The operating system (OS) is the most important


program that runs on a computer.
The OS manages and controls a computers
activities.
The popular operating systems:
1. Microsoft Windows
2. Mac OS X
3. Linux
4. UNIX
1

Operating Systems
Users and applications access the computers
hardware via the operating system.

Programs and Processes


Unix:
a multitasking, multiuser computer operating system that exists in
many variants. The original Unix was developed at AT&T's Bell
Labs research center by Ken Thompson, Dennis Ritchie, and
others.
The C programming language was designed by Dennis Ritchie as
a systems programming language for Unix.

Both Unix and the C programming language were developed by


AT&T and distributed to government and academic institutions,
which led to both being ported to a wider variety of machine
families than any other operating system.
3

Process
In computing, a process is an instance of a computer
program that is being executed. It contains the program
code and its current activity.
Depending on the operating system (OS), a process may
be made up of multiple threads of execution that execute
instructions concurrently.
A process is a dynamic entity.
PuTTY: (UNIX connection)
click putty; use following information to set up and connect
host name: alpha.fdu.edu
connection type: SSH
change keyboard under Terminal at left panel
The backspace key: control-H
The function key and keypad: VT100+
4

Process
http://www.putty.org

Process

Process
Fundamental to all operating systems is the
concept of a process.

A process consists of
1.
2.
3.
4.

Executing program
Its current values
State information
The resources used by the O.S. to manage
the execution of the process
7

UNIX Operating System


In UNIX-based operating system, at any point in time,
multiple processes appear to be executing concurrently.
The UNIX operating system run on platform that has a
single processing unit capable of supporting many active
processes.
Meaning, at any point in time only one process is actually
being worked upon.
By rapidly changing the process it is currently executing,
the UNIX operating system gives the appearance of
concurrent process execution.
8

Multiprogramming or Multitasking
allows multiple programs to run simultaneously by sharing
the same CPU. Allowing you to use a word processor to edit a
file at the same time as your Web browser is downloading a
file.

Multithreading
allows a single program to execute multiple tasks at the same
time. At the word processing editing and saving are two
tasks within the same application, run concurrently.

Multiprocessing or parallel processing


uses two or more processors together to perform subtasks
concurrently and then combine solutions of the subtasks to
obtain a solution for the entire task.
9

Program
A program is an inactive, static entity consisting of a set of
instructions and associated data.
We can consider a program to be in one of two basic formats:
1. Source program non-executable
A source program is a series of valid statements for a
specific programming language (such as C, C++, Java, ).
The source program is stored in a plain ASCII text file.

2. Executable program not displayable on the terminal of


printed by the user
An executable program is a source program that, by way
of a translating program such as a compiler, assembler,
..etc, has been put into a special format that the O.S. can
execute (run).
10

ASCII
The American Standard Code for Information
Interchange(ASCII ) is a character-encoding scheme
originally based on the English alphabet that encodes 128
specified characters.

11

/* Display Hello World 3 times */


#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <stdlib.h>
#include <unistd.h>
char
char

*cptr="Hello World\n";
buffer1[25];

void main(void)
{
void showit(char *);
int i = 0;
strcpy(buffer1, "A demonstration\n");
write(1, buffer1, strlen(buffer1)+1);
for(; i<3; ++i)
showit(cptr);
}

// static by placement

// function prototype
// automatic variable
// library function
// system call
// function call

void showit(char *p)


{
char *buffer2;
if((buffer2 = (char *) malloc((unsigned) (strlen(p)+1)))!=NULL)
{
strcpy(buffer2, p);
// copy the string from p to buffer2
printf("%s", buffer2);
// display string
free(buffer2);
// release location
}
else
{
printf("Allocation error.\n");
exit(1);
}
}

12

Basic printf conversions

malloc: Allocates main memory.


#include <stdlib.h>
void *malloc(size_t size); where size_t is unsigned int or long

13

Library Functions
Function:
A function is a collection of declarations and statements that
carries out a specific action and/or returns a value.
1. Defined by the user
2. Previously defined: stored in object code format in
library files
Object code format is a special file format that is generated
as an intermediate step when an executable program is
produced.
Like executable files, object code files are also not displayed
to the screen or printed.
Library functions: functions stored in library files
14

Library Functions
/usr/lib: The standard location for library files in most UNIX
systems.

/usr/local/lib: Ancillary library files


By convention the three-letter prefix for library file is lib and
the file extension is .a.
The UNIX archive utility ar, which maintains library files, can
be used to examine their contents.
Ex:
> ar -t /usr/lib/libc.a | pr -4 t
ar: create, modify and extract from archives
t: display a table listing the contents
pr: convert text files for printing
-4: output to screen in a four-column format
-t: omit page headers and trailers

15

You might also like