Thursday, July 30, 2009

Multithreading Models








Many Many- -to to- -One

Many user-level threads mapped to single kernel thread
· Examples:

-Solaris Green Threads

-GNU Portable Threads



ONE ONE to-to-One

















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



MANY Many -to-to Many Model
















· Allows many user level threads to be mapped to many kernel
threads
· Allows the operating system to create a sufficient number of
kernel threads
· Solaris prior to version 9
· Windows NT/2000 with the ThreadFiber package

Thread Library

  • The threads library allows concurrent programming in Objective Caml. It provides multiple threads of control (also called lightweight processes) that execute concurrently in the same memory space. Threads communicate by in-place modification of shared data structures, or by sending and receiving data on communication channels.The threads library is implemented by time-sharing on a single processor. It will not take advantage of multi-processor machines. Using this library will therefore never make programs run faster. However, many programs are easier to write when structured as several communicating processes.

Kernel Threads Kernel Threads

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

User Threads

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

Benefits

  • Responsiveness
  • Resource Sharing
  • Economy
  • Utilization of MP Architectures

Threads

SINGLE AND MULTI THREADED PROCESS

Interprocess Communication

Direct 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.
    Asymmetric variant
  • receive(id, message) – receive a message from any
    process, pid stored in id


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 is considered synchronous
  • Non-blocking is considered asynchronous
  • send and receive primitives may be either blocking or
    non-blocking.

Buffering

  • Queue of messages attached to the link; implemented in
    one of three ways.
    1. Zero capacity – 0 messages
    Sender must wait for receiver (rendezvous).
    2. Bounded capacity – finite length of n messages
    Sender must wait if link full.
    3. Unbounded capacity – infinite length
    Sender never waits.

Producer - Consumer Example

  • Producer generates an integer between 0 and 9 (inclusive), then stores it in a CubbyHole object. To make the synchronization problem more interesting, the Producer sleeps for a random amount of time between 0 and 100 milliseconds before repeating the number-generating cycle.
  • Producer generates an integer between 0 and 9 (inclusive), then stores it in a CubbyHole object. To make the synchronization problem more interesting, the Producer sleeps for a random amount of time between 0 and 100 milliseconds before repeating the number-generating cycle.

Thursday, July 16, 2009

Interprocesses Communication

  • For communication and synchronization
    –Shared memory
    –OS provided IPC
    Message system
    –no need for shared variable
    – 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

Cooperating Processes

  • Advantages of process cooperation
    –Information sharing
    –Computation speed-up
    –Modularity
    –Convenience
  • Independent process cannot affect/be affected by the execution of another process, cooperating ones can
    Issues
    –Communication
    –Avoid processes getting into each other’s way
    –Ensure proper sequencing when there are dependencies
  • Common paradigm: producer-consumer
    –unbounded-buffer - no practical limit on the size of the buffer
    –bounded-buffer - assumes fixed buffer size

Operation Process

a). Process on creation

  • Parent process creates 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

b). Process Termination

  • Process executes last statement and asks the operating system to delete 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.

Process Scheduling

a). Process 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. Processes migrate between the various queues.
b). Schedulers
  • Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue.
  • Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU.
c). Context Switch
  • 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 suppor

Concept of Process

A.) Process State

  1. new: The process is being created.
  2. running: Instructions are being executed.
  3. waiting: The process is waiting for some event to occur.
  4. ready: The process is waiting to be assigned to a processorF terminated: The process has finished execution.

B.) Process Control Block

Information associated with each process.

  1. Process ID
  2. Process staten
  3. Program counter
  4. CPU registers
  5. CPU scheduling informationn
  6. Memory-management informationn
  7. Accounting informationn
  8. I/O status information

C.) Treands

  • 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 hese resources.

Wednesday, July 8, 2009

SYSTEM BOOT

One of the most important functions that the BIOS plays is to boot up the system. When the PC is first turned on, its main system memory is empty, and it needs to find instructions immediately to tell it what to run to start up the PC. These it finds within the BIOS program, because the BIOS is in read-only permanent memory and so is always available for use, even when the rest of system memory is empty.This section takes a look at what is involved in booting the PC, including a discussion of the steps in the system boot process, and a look at the power-on self-test (POST) that is conducted whenever the system starts up

SYSTEM GENERATION

- Operating systems are designed to run on any of a class of machines; the system must be configured for each specific computer site -SYSGEN program obtains information concerning the specific configuration of the hardware system- Booting
– starting a computer by loading the kernel- Bootstrap program
– code stored in ROM that is able to locate the kernel, load it into memory, and start its execution

Virtual Machine

Virtual Machine=>A virtual machine, simply put, is a virtual computer running on a physical computer. The virtual machine emulates a physical machine in software. This includes not only the processor but the instruction set, the memory bus, any BIOS commands and critical machine hardware such as the system clock and and DMA hardware. Depending upon the machine peripheral devices are generally virtualized including storage devices like floppy drives, hard drives and CD drives. Video, keyboard and mouse support are also common. A virtual machine must look and act just like the real thing so standard software, like operating systems and applications, can run without modification.
  • Benefits=>Virtual machines have been around for a long time but they really have not become common place in many development shops. It is unfortunate since virtual machines provide so many benefits to developers and testers alike. This article will discuss some of the benefits of virtual machines and review two of the most popular virtual machine software packages available for Windows.

SYSTEM STRUCTURES

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 subproblemsLayred 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 layers.A process is a program in execution. A process needs certain resources: CPU time, memory (address space), files, and I/O devices, to accomplish its task.

SYSTEM CALLS

  • 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.
  • 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=> Information management (IM) is the collection and management of information from one or more sources and the distribution of that information to one or more audiences. This sometimes involves those who have a stake in, or a right to that information. Management means the organization of and control over the structure, processing and delivery of information.Throughout the 1970s this was largely limited to files, file maintenance, and the life cycle management of paper-based files, other media and records. With the proliferation of information technology starting in the 1970s, the job of information management took on a new light, and also began to include the field of Data maintenance. No longer was information management a simple job that could be performed by almost anyone. An understanding of the technology involved, and the theory behind it became necessary. As information storage shifted to electronic means, this became more and more difficult. By the late 1990s when information was regularly disseminated across computer networks and by other electronic means, network managers, in a sense, became information managers. Those individuals found themselves tasked with increasingly complex tasks, hardware and software. With the latest tools available, information management has become a powerful resource and a large expense for many organizations.

OPERATING SYSTEM SERVICE

  • program execution =>system capability to load a program into memory and to run it.
  • I/O operations => since user programs cannot execute I/O operations directly, the operating system must provide some means to perform I/O.
  • File-system manipulation => program capability to read, write, create, and delete files.
  • Communications => exchange of information between processes executing either on the same computer or on different systems tied together by a network. Implemented via shared memory or message passing.
  • Error detection => ensure correct computing by detecting errors in the CPU and memory hardware, in I/O devices, or in user programs.

SYSTEM COMPONENTS

  • OPERATING SYSTEM PROCESS MANAGEMENT=>In operating systems, process is defined as “A program in execution”. Process can be considered as an entity that consists of a number of elements, including: identifier, state, priority, program counter, memory pointer, context data, and I/O request. The above information about a process is usually stored in a data structure, typically called process block.
  • 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.
  • SECONDARY STORAGE MANAGEMENT=>Since main memory (primary storage) is volatile and too small to accommodate all data and programs permanently, the computer system must provide secondary storage to back up main memory.Most modern computer systems use disks as the principle on-line storage medium, for both programs and data.The operating system is responsible for the following activities in connection with disk management:Free space managementStorage allocationDisk scheduling
  • PROTECTION SYSTEM=>Protection System is rather anyware, i.e commercial software that applies extremely annoying ads to convince users of the need to buy it (buying Protection System means registering this program for at least one year period). We have to stress on that registering Protection System is no escape from its alerts as the hackers’ design is to get endless cashflow from user who once agreed to pay. That is, registered Protection System will ask for updates and extended registration. There is thus ho way to get rid of Protection System’s noisy ads but to remove Protection System entirely. to detect the infections harming your computer system and to remove Protection System automatically.
  • COMMAND INTERPRETER SYSTEM=>A hardware accelerated I/O data processing engine to execute a minimum number of types of I/O data processing commands in response to a stimulus from a host computer. The data processing engine, referred to as a command interpreter includes a command queue, a logic unit, a multiple purpose interface, at least one memory, and a controlling state machine, that each operate in concert with each other and without software control. The types of commands executed by the command interpreter can include, but are not limited to, an Initialize, Copy, DMA Read, DMA Write, Cumulative Exclusive OR, Verify, Compare, and ECC Check. The execution of commands that specify a source data location and a destination data location are characterized by a plurality of reads to an internal cache from the source data location for each bulk write from the internal cache to the destination data location. The locations of the data operated on by the command interpreter include a local I/O controller memory and a non-local I/O controller memory accessible to the command interpreter by way of an I/O bus.