HOME

Top 10 List of Week 06

  1. Process Memory
    Process memory is divided into 4 sections:
    • Text: Comprises the compiled program code, read in from non-volatile storage when the program is launched.
    • Data: Stores global and static variables, allocated and initialized prior to executing main.
    • Heap: Used for dynamic memory allocation, and is managed via calls to new, delete, malloc, free, etc.
    • Stack: Used for local variables. Space on the stack is reserved for local variables when they are declared ( at function entrance or elsewhere, depending on the language ), and the space is freed up when the variables go out of scope.
  2. Process State
    Processes can take place in one of the 5 states:
    • New : Creating a new process
    • Ready : The process has all the resources available that it needs to run, but the CPU is not currently working on this process’s instructions.
    • Running : CPU working on this process’s instructions
    • Waiting : Process cannot be run because it is waiting for some resource to become available or for some event to occur/finish
    • Terminated : Process is complete
  3. Process Control Block(PCB)
    PCB is a fata structures containing the information of a process
    • Process State
    • Process ID, and parent process ID.
    • CPU registers and Program Counter:These need to be saved and restored when swapping processes in and out of the CPU.
    • CPU-Scheduling information:Priority information and pointers to scheduling queues.
    • Memory-Management information :Example: page tables or segment tables.
    • Accounting information: User and kernel CPU time consumed, account numbers, limits, etc.
    • I/O Status information : Devices allocated, open file tables, etc.
  4. fork()
    The fork() system call creates a process that becomes an replica of the parent process that it is forking. After a new child process is created, both processes will execute the next instruction. Therefore, we have to distinguish the parent from the child. This can be done by testing the returned value of fork():
    • negative value: the creation of child process was unsuccesful
    • zero
    • positive value: the process ID of the child process, to the parent.
  5. exec()
    Exec() system call creates a new process from existing executable . So the problem of the new process having duplicate executable can be solved using exec(). This act is also referred to as an overlay. It is especially important in Unix-like systems, although exists elsewhere. As a new process is not created, the process identifier (PID) does not change, but the machine code, data, heap, and stack of the process are replaced by those of the new program.

  6. Interprocess Communication (IPC)
    Interprocess communication is the mechanism by which multiple processes can communicate with each other. This is one of the important feature provided by the operating system. These are the advantages of using IPC:
    • Information sharing: Many processes will be interested in the same piece of information(a shared file or a library).
    • Computational speedup: We cab break a task into subtasks and let each subtask run on a separate processor. These tasks can then use IPC for exchanging information. This makes the program run fast.
    • Modularity: A program can be divided into multiple chunks of code each performing a specific function. Maintaining and debugging the code will then be easy.
    • Convenience: Even an individual user may work on many tasks at the same time. For instance, a user may be editing, listening to music, and compiling in parallel.
  7. Thread
    A thread,also known as lightweight process, is a path of execution within a process. A process can contain multiple threads (multithread). The idea of multithreading is to achieve parallelism by dividing a process into multiple threads. For example, in a browser, multiple tabs can be different threads.

  8. Process vs Thread
    • Threads within the same process run in a shared memory space, while processes run in separate memory spaces.
    • Threads are not independent of one another like processes are, and as a result threads share with other threads their code section, data section, and OS resources (like open files and signals). But, like process, a thread has its own program counter (PC), register set, and stack space.
  9. Advantages of Thread:
    • Responsiveness: If the process is divided into multiple threads, if one thread completes its execution, then its output can be immediately returned.
    • Faster context switch: Context switch time between threads is lower compared to process context switch. Process context switching requires more overhead from the CPU.
    • Effective utilization of multiprocessor system: If we have multiple threads in a single process, then we can schedule multiple threads on multiple processor. This will make process execution faster.
    • Resource sharing: Resources like code, data, and files can be shared among all threads within a process.
    • Communication: Communication between multiple threads is easier, as the threads shares common address space. while in process we have to follow some specific communication technique for communication between two process.
  10. Concurrency
    Concurrency is the execution of the multiple instruction sequences at the same time. It happens in the operating system when there are several process threads running in parallel. Concurrency results in sharing of resources result in problems like deadlocks and resources starvation.But, concurrency helps in techniques like coordinating execution of processes, memory allocation and execution scheduling for maximizing throughput.