Programming and Operating Systems

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/33

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

34 Terms

1
New cards

Process

a running programme. a process is active/dynamic whereas a program is a passive entity

2
New cards

What does a process consist of?

Process text (code of the program)

program counter (the address of the next instruction to be executed)

process stack (temporary data eg local variables, return addresses etc)

data section (global variables)

3
New cards

What must an operating system be able to do at minimum?

Create: a new process

Destroy: /terminate a process

Wait: or pause a process until some event occurs

Suspend/resume: like wait but more explicitly evoked

Status report: information about a process eg how long it has run for, how much memory has been allocated to it etc

4
New cards

What is the state of a process?

the state of a process if defined (in part) by the current activity of that process

5
New cards

Name and describe the five possible states of process activity

New: the process is being created

Running: Instructions are being executed

Blocked: (also called waiting) process is waiting for some event to occur

Ready: The process is waiting to be assigned to a processor

Termination: The process has finished execution

6
New cards

Sketch a diagram of process life cycle

New → Running → Blocked → Ready → Termination

7
New cards

If process A initiates process B then:

process A is the Parent

Process B is the Child

8
New cards

PID

Process identification number, all processes have a unique PID

9
New cards

What is does an operating system do ?

provides an interface between users and the computer’s hardware.

allocates resources: it gives access to the CPU, RAM, mass storage, etc., and makes efficient use of resources

10
New cards

The fork() function creates a child process. What does it return?

the child’s PID to the parent, and 0 (zero) to the child

11
New cards

What does getpid() do?

returns value of the process PID

12
New cards

What does getppid() do?

Returns the value of the processes parent PID

13
New cards

execlp() function

allows you to overlay child process with another program

14
New cards

When might process termination occur?

  1. the process executes its last instruction and asks OS to delete it

  2. Parent terminates child process because, subproc has exceeded allocated resources or task assigned to subproc is no longer required

15
New cards

Signals

a form of communication from one processe to another eg kill()

16
New cards

signal()

with signal() we can send a signal that tells the process to preform a specific action when it recieves a SIGUSR1 OR SIGUSR2 (user defined signals) signal

17
New cards

IPC

inter process communication, provides a logical communication link via a message passing facility with 2 basic operations: send and recieve message

18
New cards

Two processes that are executing on the same computer can be either independent or cooperating. Explain what is meant by independent in this context

They cannot affect/ be affected by the execution of the other

19
New cards

Two processes that are executing on the same computer can be either independent or cooperating. Explain what is meant by cooperating in this context

They can be affected or affect by the execution of the other

20
New cards

Name 4 advantages facillitated by allowing process communication

  1. Information sharing

  2. Modularity (different procs might be dedicated to different system functions)

  3. Convenience

  4. Computational speed (on a multi processing system, tasks are sub divided and executed at the same time on different processors

21
New cards

Why do cooperating processes require communication?

to share data and sync their actions

22
New cards

What does the producer-consumer model describe?

Communication between cooperative processes

One process might have information it wants to produce for consumption by another process. this can be done with a mutual buffer so that the producer writes to the buffer and the consumer reads from it

23
New cards

Bounded buffer

There is a strict limit on the size of the buffer. If the buffer is full then the produced must wait until the consumer removes some data

24
New cards

Unbounded buffer

There is no size limit on the buffer. The prodcucer can produce and write to the buffer for as long as it wants to

25
New cards

Name and describe the 2 ways a buffer may be implemented

  1. physically: by a set of shared variables (eg shared memory addresses). Implemented by programmer

  2. Logically: by message passing via an interprocess communication facility. implemented by OS

26
New cards

Disadvantages of Direct Communication IPC

  1. processes must have details of each other before communicating

  2. only 1 link per pair of processes

  3. one 2 processes can communicate at a time

27
New cards

Disadvantages and solutions for Indirect Communication IPC

Disadvantage: If one process shares data through a shared mailbox with multiple processes, which process gets to read the data?

Solution:

-The Mailbox is “owned” by only one proc. Then several procs can
write to it, but only one can read.
- Mailboxes are owned only by Operating System. Permissions then
granted to process to create and delete mailboxes, and to send or recieve messages

28
New cards

Symmetric vs Aysmmetic addressing

Symmetric → both processes need to know each others ID (direct communication) / name of shared mailbox (indirect)

Aysemetric → only the sender needs to know the recievers ID (direct)/ name of mailbox (indirect)

29
New cards

Indirect communication

number of ports (Mailboxes) in the system.
Each has a unique ID.
• For procs to communicate they just need to know the name of the
shared mailbox.
More that two procs can share a mailbox.
Two procs may share more than one mailbox.

30
New cards

pipe()

A pipe is a means of communication. It is a form of symetric direct communication

Using the pipe(fd) function, one process creates a pipe. Here fd is
a int array with two elements.
• To put a message into the pipe, write to name[1]
• To read a message from the pipe, read from name[0]

31
New cards

Program Counter (PC)

Tells the OS which line of code is being executed

32
New cards
33
New cards
34
New cards