Thursday, July 30, 2009

operating system 5


Thread


*Single Threaded Process & *Multi-threaded Proces








-Benefits of Multi-threaded Programming
*Responsiveness - Parts of a program can continue running even if parts of it are blocked. Book points out that a multi-threaded web browser could still allow user interaction in one thread while downloading a gif in another thread…
*Resource Sharing – pros and cons here. By sharing memory or other resources (files, etc.) the threads share the same address space. (there are issues here…)
*Economy – since threads share resources, it is easier to context-switch threads than context-switching processes. This should be clear.
*Utilization of MP Architectures – there will be significant increases in performance in a multiprocessor system, where different threads may be running simultaneously (in parallel) on multiple processors.
*Of course, there’s never ‘a free lunch,’ as we will see later. (There’s always a cost…; nothing this good comes free. J )

-User Thread


^Thread management done by user-level threads library
^Three primary thread libraries:
-POSIX Pthreads
-Win32 threads


-Kernel Thread


*Supported by the Kernel
*Examples
-Windows XP/2000
-Solaris
-Linux
-Tru64 UNIX
-Mac OS X


-Thread Library


-Programmers need help and receive development help via thread libraries germane to specific development APIs..
*A thread library provides an API for creating and managing threads. Java has an extensive API for thread creation and management.
-There are two primary ways to implement thread libraries:
1. Provide thread library entirely in user space – no kernel support
-All code and data structures for the library exist in user space.
-And, invoking a local function call to the library in user space is NOT a system call, but rather a local function call. (this is good).
2. Implement a kernel-level library supported by the OS.
-Here, code and data structures exist in kernel space.
-Unfortunately, in invoking a function call to the library, there is a system call to the kernel for support.
-Multithreading Model
+Many-to-one Model

•Each user thread maps to one kernel thread
•Is this implementation good (concurrency vs. efficiency)?
–Good concurrency, why? (blocking syscall does not affect other threads)
–Expensive, why? (user-thread creation -> kernel-thread creation)
•How to have both good concurrency and efficiency?






+One-to-one model

*Each user-level thread maps to kernel thread
*Examples
-Windows NT/XP/2000
-Linux
-Solaris 9 and later


+Many-to-many model


•Many user threads are mapped to a smaller or equal number of kernel threads. –Why is this better than Many-to-one? (concurrency & multi-processor) –Why is this better than one-to-one? (efficiency) •Like one-to-one concurrency? –Two-level model



















operating system 4

Interprocess Communication
-Inter-process communication (IPC) is a set of techniques for the exchange of data among multiple
threads in one or more processes. Processes may be running on one or more computers connected by a network. IPC techniques are divided into methods for message passing, synchronization, shared memory, and remote procedure calls (RPC). The method of IPC used may vary based on the bandwidth and latency of communication between the threads, and the type of data being communicated.
-Derict Communication
*Processes must name each other explicitly:
-send (P, message) – send a message to process P
-receive(Q, message) – receive a message from process Q
*Properties of communication link
-Links are established automatically
-A link is associated with exactly one pair of communicating processes
-Between each pair there exists exactly one link
-The link may be unidirectional, but is usually bi-directional
-Indirect Communication
*Operations
-create a new mailbox
-send and receive messages through mailbox
-destroy a mailbox
*Primitives are defined as:
send(A, message) – send a message to mailbox A
receive(A, message) – receive a message from mailbox A
-Synchronization
- Message passing may be either blocking or non-blocking

*Blocking send has the sender block until the message is received
*Nonblocking send
-Non-blocking send has the sender send the message and continue
*blocking recieve
- Blocking receive has the receiver block until a message is available
*Nonblocking recieve
-Non-blocking receive has the receiver receive a valid message or null

Buffering
*Zero capacity - 0 messagesSender must wait for receiver (rendezvous)
*Bounded Capacity - finite length of n messagesSender must wait if link full
*Unbounded Capacity- infinite length Sender never waits

Producer
*producer

a person who produces.
*consumer
a person or thing that consumes.

Thursday, July 16, 2009

Operating system 4

1.The concept of process

-An operating system executes a variety of programs:
=Batch system – jobs
=Time-shared systems – user programs or tasks
-Textbook uses the terms job and process almost interchangeably.
-Process – a program in execution; process execution must progress in sequential fashion.
-A process includes:
=program counter
=tack
=data section
.


A-Process State

-As a process executes, it changes state
-new: The process is being created.
-running: Instructions are being executed.
-waiting: The process is waiting for some event to occur.
-ready: The process is waiting to be assigned to a process.
-terminated: The process has finished execution.








B-Process Control Blocked

Information associated with each process.
-Process state
-Program counter
-CPU registers
-CPU scheduling information
-Memory-management information
-Accounting information
-I/O status information






Process Control Block (PCB)



CPU Switch From Process to Process





C-Threads

A thread of execution results from a fork of a computer program into two or more concurrently running tasks. The implementation of threads and processes differs from one operating system to another, but in most cases, a thread is contained inside a process. Multiple threads can exist within the same process and share resources such as memory, while different processes do not share these resources.










A process with two threads of execution

On a single processor, multithreading generally occurs by time-division multiplexing (as in multitasking): the processor switches between different threads. This context switching generally happens frequently enough that the user perceives the threads or tasks as running at the same time. On a multiprocessor or multi-core system, the threads or tasks will generally run at the same time, with each processor or core running a particular thread or task. Support for threads in programming languages varies: a number of languages simply do not support having more than one execution context inside the same program executing at the same time. Examples of such languages include Python, and OCaml, because the parallel support of their runtime support is limited by the use of a central lock, called "Global Interpreter Lock" in Python, "master lock" in Ocaml. Other languages may be limited because they use threads that are user threads, which are not visible to the kernel, and thus cannot be scheduled to run concurrently. On the other hand, kernel threads, which are visible to the kernel, can run concurrently.
Many modern
operating systems directly support both time-sliced and multiprocessor threading with a process scheduler. The kernel of an operating system allows programmers to manipulate threads via the system call interface. Some implementations are called a kernel thread, whereas a lightweight process (LWP) is a specific type of kernel thread that shares the same state and information.


Operating system 4



2.Process Sheduling
Scheduling is a key concept in
computer multitasking and multiprocessing operating system design, and in real-time operating system design. In modern operating systems, there are typically many more processes running than there are CPUs available to run them. Scheduling refers to the way processes are assigned to run on the available CPUs. This assignment is carried out by software known as a scheduler.

A-Scheduling Queues
-Job queue – set of all processes in the system.
-Ready queue – set of all processes residing in main memory, ready and waiting to execute.
-Device queues – set of processes waiting for an I/O device.
-Process migration between the various queues.

Representation of Process Scheduling







B-Schedulers



Types of operating system schedulers




-Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue.

-Mid-term Scheduler

The mid-term scheduler, present in all systems with
virtual memory, temporarily removes processes from main memory and places them on secondary memory (such as a disk drive) or vice versa. This is commonly referred to as "swapping out" or "swapping in" (also incorrectly as "paging out" or "paging in"). The mid-term scheduler may decide to swap out a process which has not been active for some time, or a process which has a low priority, or a process which is page faulting frequently, or a process which is taking up a large amount of memory in order to free up main memory for other processes, swapping the process back in later when more memory is available, or when the process has been unblocked and is no longer waiting for a resource.

-Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU.


Addition of Medium Term Scheduling

-Short-term scheduler is invoked very frequently (milliseconds) Þ (must be fast).
-Long-term scheduler is invoked very infrequently (seconds, minutes) Þ (may be slow).
-The long-term scheduler controls the degree of multiprogramming.
-Processes can be described as either:
-I/O-bound process – spends more time doing I/O than computations, many short CPU bursts.
-CPU-bound process – spends more time doing computations; few very long CPU bursts.

C-Context Swicth
-When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process.
-Context-switch time is overhead; the system does no useful work while switching.
-Time dependent on hardware support.

Operating system 4

3.Operations on Processes

A-Process Creation
-Parent process create children processes, which, in turn create other processes, forming a tree of processes.
-Resource sharing
-Parent and children share all resources.
-Children share subset of parent’s resources.
-Parent and child share no resources.
-Execution
-Parent and children execute concurrently.
-Parent waits until children terminate.

Process creation(cont.)
-Address space
-Child duplicate of parent.
-Child has a program loaded into it.
-UNIX examples
-fork system call creates new process
-exec system call used after a fork to replace the process’ memory space with a new program.


B-Process Termination

-Process executes last statement and asks the operating system to decide it (exit).
-Output data from child to parent (via wait).
-Process’ resources are deallocated by operating system.
-Parent may terminate execution of children processes (abort).
-Child has exceeded allocated resources.
-Task assigned to child is no longer required.
-Parent is exiting.
-Operating system does not allow child to continue if its parent terminates.
-Cascading termination.



Thursday, July 9, 2009

Operating system 4


4.Cooperating Process
- Independent process cannot affect or be affected by the execution of another process.
-Cooperating process can affect or be affected by the execution of another process
-Advantages of process cooperation
-Information sharing
-Computation speed-up
-Modularity
-Convenience


5.Inter Process Communication



-Mechanism for processes to communicate and to synchronize their actions.
-Message system – processes communicate with each other without resorting to shared variables.
-IPC facility provides two operations:
-send(message) – message size fixed or variable
-receive(message)
-If P and Q wish to communicate, they need to:
-establish a communication link between them
-exchange messages via send/receive
-Implementation of communication link
-physical (e.g., shared memory, hardware bus)
-logical (e.g., logical properties)


-------------------------------------------------------------------------------------------------

1.What are the major activities of the operating system with regards to Process management.
-process creation and deletion
-process suspension and resumption
-provision of mechanism for:
>process synchronization
>process communication
>deadlock handling

2.What are the major activities of the Operating system regards to Memory Management.
-keep track of which parts of memory are currently being used and by whom
-decide which processes to load when memory space becomes available
-allocate and deallocate memory space as needed.

3.What are the major activities of the Operating system Secondary Storage Management.
-Free space memory
-Large allocation
-disk scheduling

4.What are the major activities of the Operating system File Management.
-File creation and deletion
-Directory creation and deletion
-support of primitives for manipulating files and directories
-Mapping files onto secondary storage -
-File backup on stable (nonvolatile) storage media

5.What is the purpose of the Command Interpreter.
-process creation and management
-I/O handling
-Secondary Storage Management
-File system access
-Protection
-Networking


Tuesday, July 7, 2009

Virtual Machine

In
computer science, a virtual machine (VM) is a software implementation of a machine (computer) that executes programs like a real machine.A virtual machine was originally defined by Popek and Goldberg as "an efficient, isolated duplicate of a real machine". Current use includes virtual machines which have no direct correspondence to any real hardware.[1]
Virtual machines are separated into two major categories, based on their use and degree of correspondence to any real machine. A system virtual machine provides a complete
system platform which supports the execution of a complete operating system (OS). In contrast, a process virtual machine is designed to run a single program, which means that it supports a single process. An essential characteristic of a virtual machine is that the software running inside is limited to the resources and abstractions provided by the virtual machine -- it cannot break out of its virtual world.

-Implementation

is the realization of an application, or execution of a
plan, idea, model, design, specification, standard, algorithm, or policy.
In
computer science, an implementation is a realization of a technical specification or algorithm as a program, software component, or other computer system. Many implementations may exist for a given specification or standard. For example, web browsers contain implementations of World Wide Web Consortium-recommended specifications, and software development tools contain implementations of programming languages.

-Benefits

Virtual Machines, AKA "Virtualization," is currently a popular topic in computerization. For the benefit of people who are unfamiliar with using this computer technology, this article will explain the benefits of using virtualization.

-Examples


Zones are not virtual machines, but an example of "operating-system virtualization".
This includes other "virtual environments" (also called "virtual servers") such as Virtuozzo, FreeBSD Jails, Linux-VServer, chroot jail, and OpenVZ. These provide some form of encapsulation of processes within an operating system. These technologies have the advantages of being more resource-efficient than full virtualization and having better observability into multiple guests simultaneously; the disadvantage is that, generally, they can only run a single operating system and a single version/patch level of that operating system - so, for example, they cannot be used to run two applications, one of which only supports a newer OS version and the other only supporting an older OS version on the same hardware. However, Sun Microsystems has enhanced Solaris Zones to allow some zones to behave like Solaris 8 or Solaris 9 systems by adding a system call translator.





-System Generation

*A group of interdependent items that interact regularly to perform a task.

*An established or organized procedure or a method.



-System Boot

The typical computer system
boots over and over again with no problems, starting the computer's operating system (OS) and identifying its hardware and software components that all work together to provide the user with the complete computing experience In order for a computer to successfully boot, its BIOS, operating system and hardware components must all be working properly; failure of any one of these three elements will likely result in a failed boot sequence.








Thursday, July 2, 2009


System Structure


-Simple Structure

View the OS as a series of levels
Each level performs a related subset of functions
Each level relies on the next lower level to perform more primitive functions
This decomposes a problem into a number of more manageable subproblems

-Layered Approach

The operating system is divided into a number of layers (levels), each built on top of lower layers. The bottom layer (layer 0), is the hardware; the highest (layer N) is the user interface. With modularity, layers are selected such that each uses functions (operations) and services of only lower-level layersProperties
Simplicity of construction.
Simplicity of Debugging
Problems
Precise definition of layers
Example: Memory manager requires device driver of backing store (due to virtual memory) The device driver requires CPU scheduler (since if the driver waits for IO, another task should be scheduled) CPU scheduler may require virtual memory for large amount of information of some processes Less efficiency: due to the number of layers a request should pass .
System Calls
In computing, a system call is the mechanism used by an application program to request service from the operating system based on the monolithic kernel or to system servers on operating systems based on the microkernel-structure.

-Process Control
Process control is a statistics and engineering discipline that deals with architectures, mechanisms, and algorithms for controlling the output of a specific process. See also control theory.
For example, heating up the temperature in a room is a process that has the specific, desired outcome to reach and maintain a defined
temperature (e.g. 20°C), kept constant over time. Here, the temperature is the controlled variable. At the same time, it is the input variable since it is measured by a thermometer and used to decide whether to heat or not to heat. The desired temperature (20°C) is the setpoint. The state of the heater (e.g. the setting of the valve allowing hot water to flow through it) is called the manipulated variable since it is subject to control actions.
A commonly used control device called a
programmable logic controller, or a PLC, is used to read a set of digital and analog inputs, apply a set of logic statements, and generate a set of analog and digital outputs. Using the example in the previous paragraph, the room temperature would be an input to the PLC. The logical statements would compare the setpoint to the input temperature and determine whether more or less heating was necessary to keep the temperature constant. A PLC output would then either open or close the hot water valve, an incremental amount, depending on whether more or less hot water was needed. Larger more complex systems can be controlled by a Distributed Control System (DCS) or SCADA system.
In practice, process control systems can be characterized as one or more of the following forms:
Discrete – Found in many manufacturing, motion and packaging applications. Robotic assembly, such as that found in automotive production, can be characterized as discrete process control. Most discrete manufacturing involves the production of discrete pieces of product, such as metal stamping.
Batch – Some applications require that specific quantities of raw materials be combined in specific ways for particular durations to produce an intermediate or end result. One example is the production of adhesives and glues, which normally require the mixing of raw materials in a heated vessel for a period of time to form a quantity of end product. Other important examples are the production of food, beverages and medicine. Batch processes are generally used to produce a relatively low to intermediate quantity of product per year (a few pounds to millions of pounds).
Continuous – Often, a physical system is represented though variables that are smooth and uninterrupted in time. The control of the water temperature in a heating jacket, for example, is an example of continuous process control. Some important continuous processes are the production of fuels, chemicals and plastics. Continuous processes, in manufacturing, are used to produce very large quantities of product per year(millions to billions of pounds).

File management
-In computing, a file system (often also written as filesystem) is a method for storing and organizing computer files and the data they contain to make it easy to find and access them. File systems may use a data storage device such as a hard disk or CD-ROM and involve maintaining the physical location of the files, they might provide access to data on a file server by acting as clients for a network protocol (e.g., NFS, SMB, or 9P clients), or they may be virtual and exist only as an access method for virtual data (e.g., procfs). It is distinguished from a directory service and registry.
More formally, a file system is a special-purpose
database for the storage, organization, manipulation, and retrieval of data.
Device Management
Device Management is a set of technologies, protocols and standards used to allow the remote management of mobile devices, often involving updates of firmware over the air (FOTA). The network operator, handset OEM or in some cases even the end-user (usually via a web portal) can use Device Management, also known as Mobile Device Management, or MDM, to update the handset firmware/OS, install applications and fix bugs, all over the air. Thus, large numbers of devices can be managed with single commands and the end-user is freed from the requirement to take the phone to a shop or service center to refresh or update.
For companies, a Device Management system means better control and safety as well as increased efficiency, decreasing the possibility for device downtime. As the number of smart devices increases in many companies today, there is a demand for managing, controlling and updating these devices in an effective way. As mobile devices have become true computers over the years, they also force organizations to manage them properly. Without proper management and security policies, mobile devices pose threat to security: they contain lots of information, while they may easily get into wrong hands. Normally an employee would need to visit the IT / Telecom department in order to do an update on the device. With a Device Management system, that is no longer the issue. Updates can easily be done "over the air". The content on a lost or stolen device can also easily be removed by "wipe" operations. In that way sensitive documents on a lost or a stolen device do not arrive in the hands of others.

Information Maintenance
Operating System Services

Operaring System Structures

-System Components

Operating Systems Process Management


Process management is an integral part of any modern day
operating system (OS). The OS must allocate resources to processes, enable processes to share and exchange information, protect the resources of each process from other processes and enable synchronisation among processes. To meet these requirements, the OS must maintain a data structure for each process, which describes the state and resource ownership of that process, and which enables the OS to exert control over each process.


Main Memory Management


Memory management is the act of managing
computer memory. In its simpler forms, this involves providing ways to allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. The management of main memory is critical to the computer system.
Virtual memory systems separate the memory addresses used by a process from actual physical addresses, allowing separation of processes and increasing the effectively available amount of RAM using disk swapping. The quality of the virtual memory manager can have a big impact on overall system performance.
Garbage collection is the automated allocation, and deallocation of computer memory resources for a program. This is generally implemented at the programming language level and is in opposition to manual memory management, the explicit allocation and deallocation of computer memory resources.


File management


The Miller Column browser from GNUstep is a type of Navigational file manager.

file manager or file browser is a
computer program that provides a user interface to work with file systems. The most common operations used are create, open, edit, view, print, play, rename, move, copy, delete, attributes, properties, search/find, and permissions. Files are typically displayed in a hierarchy. Some file managers contain features inspired by web browsers, including forward and back navigational buttons.
Some file managers provide
network connectivity such as FTP, NFS, SMB or WebDAV. This is achieved either by allowing the user to browse for a server, connect to it and access the server's file system like a local file system, or by providing its own full client implementations for file server protocols.
I/O System Management

All I/O instructions are privileged instructions.• Must ensure that a user program could never gain control ofthe computer in monitor mode (i.e., a user program that, aspart of its execution, stores a new address in the interruptvector
Second Storage Management

Secondary storage management is a classical feature of database management systems. It is usually supported through a set of mechanisms. These include index management, data clustering, data buffering, access path selection and query optimization.
None of these is visible to the user: they are simply performance features. However, they are so critical in terms of performance that their absence will keep the system from performing some tasks (simply because they take too much time). The important point is that they be invisible. The application programmer should not have to write code to maintain indices, to allocate disk storage, or to move data between disk and main memory. Thus, there should be a clear independence between the logical and the physical level of the system.
Protection System

Protection refers to a mechanism for controlling access by programs, processes, or users to both system and user resources.The protection mechanism must:•distinguish between authorized and unauthorized usage.•specify the controls to be imposed.•provide a means of enforcement.
Command - interpreter System
A command interpreter is the part of a computer operating system that understands and executes commands that are entered interactively by a human being or from a program. In some operating systems, the command interpreter is called the shell.
A program which reads textual commands from the user or from a file and executes them. Some commands may be executed directly within the interpreter itself (e.g. setting variables or control constructs), others may cause it to load and execute other files.