0% found this document useful (0 votes)
29 views55 pages

Os Process and Memory Management

Most important answer

Uploaded by

adhura.khwab417
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
29 views55 pages

Os Process and Memory Management

Most important answer

Uploaded by

adhura.khwab417
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 55
. Process Management 2.1 Introduction Whenever we talk of computer, we generally mean CPU or processor. This processor is important and thus which job to be assigned to processor, how it is to be assigned is question of discussion, The operating system as a Processor Manager is responsible for creation and deletion of user and system process in scheduling of processes, their synchronisation, deadlock handling ste. A Process is program in execution. In. present ‘scenerio,\\Process is unit_of_work done by computer. 2,2 Process Definition \—— The term ‘Process’ was first used by designers in early 1960. The difference between a and “a program is confusing, but ‘crucial! In’ general, f under on. To execute an_application program, the operati arrange s is like compiliers, assemblers, linker_« :_ execution _of each- of these system licd_a process.) Thus, to execute an application program, the computer system has to perform ny processes Le. it has to execute many other programs constituting the system software. When »perating system is booted, several processes are ereated. (These processes can be categorised Li Foreground processes + (ii) Background processes ‘oreground processes as\he_name-indicate are those which interact with (human) users d_ perform work for them. an “Background processes are\ not_associated with particular_users, but have some specific ample in Windows 95/98 machines, typing CTRL-ALT: ing. Processes that stay in the background,to handle some activity such as mail, Webpages, news, printing and so on are > daemons, can P 3 _ tl r y that “program is_a_passive entity wl rocess, in_active entity as 1 er execution 16 Pro TOCESs.Y i Se Soc 2.2.1 Process States or various stages through which a process pass js called it’s life cycle and this of a process canbe divid®T into” several” sta slate, each with certain characteristics es a aan fat exec s PepiGeruoasset be follanig siatcs F is stale indicates that the process has been created. The PCB has bare minimum rocess indicates that the process is waiting to be alloca a processary All ready processes (Kept in queue called as Ready Queue) Keeps waiting-for TRE To echnoemted by operating system in order to run. A program called scheduler which a part of operating system, picks up one ready process for execution by passing a control to i Running : This state of a process indicates that instructions are being executed. ; Waiting : This state of a process indicates that a Waiting process lacks some resource other than the CPO: Such processes are normally not considered for Turthér execution until the ' related conditions are fulfilled or the resources are made available to process. that the process has finished execution, Al Terminated Terminated : This state of a process indica the_resources allocated are released for furth Meaium term Submitted schedular Long term’ schedular Completion schedular Wait for of /O or VO of any. ‘ otherEvent other event 7 Process Status 3 Process Control V It is very important to ensure that processes run correctly and the states of each proces are independent of cach other. Thusfto control the various processes, the operating system maintaia a table (an_array of structures) called the pro ible, The process table contains one cat} per process. In general these enteries are referre céss Control Blocks (PCB's). The ent! contains several details related with a specific process, which includes. (i) Pr .ss_number : Each process is identified by its process number, called Process 1D eee ee a - — i is J - e. ‘ ing System (ii) Priority : What is the priority assigned to the process. (iii) Process state : Each process may be’ in any of the states discussed above like new, rtady, running, “waiting and “Termination. ’ (iv) Program counter : It indicates the address of next instruction to be exccuted in the process. 0) ters : They_include accumulator, gencral_purpose registers, index registers’ ete. Pointer | Process state isters memory limits list of open files Accounting Information 1/O Status Information A sample PCB (vi) Accounting information : It includes actual CPU timé used in executing a process. (vii) /O* status information : It_includes_out_standing I/O requests, List of open files, information about allocation’ of peripheral devices to processes ete. (uli) Processor scheduling details : It includes a priority of a process, address to scheduling queues and many other details. 2.4 Initialising the Operating System | When we power on the computer, the first step is execution of the program stored at boot strap address Le. the address-of-the first instruction {0 be exceuted isoaded-in.the Program Counte#. This is generally executed by hardware bootup sequence. This first program defines the pr of the system. It create Operating System environment to support its processes, threads, objects, files and other resources. most primitive oper computation model Once the Operating System is loaded, it takes control of all, hardware resources, initialise various device states, process state and data structures. When the bootstrap code is executed, an ‘The memory part of the address space is created by the source program a as shown below. The linkage between Job and Address Space can be shown as a User Creates User Specifies eo ‘Job Step ‘System Creates v4 Process Traffic Controller ‘Scheduler as. ‘Component File System ‘Main Program, ‘Subroute A ‘Subroute B User Speciic ‘Subroute C task Address space for Address space for CPU Process VO Process 2.6 Process Abstraction When a Process need a resource for it’s execution and if the resources are not available then the process is blocked from execution, It is possible that resources are available and at the same instant two or more process demands them. The process which wins the resource allocation comptetion, is allocated the resources and other waits for their chance to get resources, Thus OS need to keep track of resource available, in demand and already allocated, This tracking is possible by resource and process descriptors. Process descriptors : The process description is ically the data structure which keep> details related to state of the process, This in general include the following 1. Process Register contents when the process was last suspended ae . 2, Processor state 3. Processor’s memory state % 4. The resources already allocated to process. 5. The resources required by process. 6. If possible, when last resource was used, the expected time of resource availibility ete. 2.7 The Resource Abstraction \The operating system is also sometimes called as Resource N as it is one of the major role of Operating System to ensure that all the resources are properly wilised ie} fesourees . are allocated when required or released to resources pool, when not in use oF Ireed. In major cases, resource manager is a part of Operating System but in few case it is separate entity. Resource can block a process from exccutingLIf a process need printer and Printer is not available the device manager blocks the process from subsequent execution until the Printer t aia is made available. Release Resource Manager| Allocate \ Release | | Allocate 7 tC met Process F neivs 4 Tt: {5 Request Queue 12 & z , Release/Allocate ® The resources can be rcusable resource like Printer, Hard disk cle. These resources once allocated and uscd are again scnt to resource pool for further usages. The mere abstract resource such as input data, which cause a process to be blocked! on request are called as consumable resource. The reusable resources are always well defined in a system and are limited, whereas consumable resources are unbounded and depend upon situation. 2.8 Process Hierarchy ‘The Operating System supporting process concepts, need to provide some means t@ create all the proc red. Tn a single application system,|it is posible to have all Wl to Be present when system’ comes up. In mulliprocess environment, some hierarchy is required to he implicitly defined 10 plan proper resource allocation and processes execution. The hierarchy is generated from the process creation mechanism. it ple child process and thus a child lly the running process creates multiple cl wus a ch have Bay os pleat ete where as a parent process can have multiple child processes shown below : Fach Operating System has separate process hierarchies mechanism. In UNIX, Processes are created by FORK system call, which creates twin copy of the calling process. After FORK a call, the parent continnes running, in parallel with child, Based on requirement, parent can fork i off more children §0 at particular instant, parent may have many executing children, The children t mm turn can'exetute FORK so it is possible-to got a tree of Process. f Ne_MS-DOS, i system call is there to load Specified executable file into memory and ; execute it_as_a_child_process. Unlike UNIX, in. M! fond specified executable file int y_an¢ “DOS parent process is eet td mand thus parent and! child do mot run im_paralles, 2.9 CPU Scheduling 7 \When ou in the inthe chit has Tinished exeent computer ports ruuki—programming, it frequently has multiple processes tthe CPU at the same time, as in mulfprogramming more: than one program reside main_memory] This situation occur mater (WO OF MOTE FOCESSES are simullancously ready state. If only one CPU is avail lable, a decision has to be made which Process to fun next. The part of the operating system that makes the choice ig called the scheduler algorithm it uses is called the scheduling algorithny, Thus, we and the in define that a scheduler is an operating ssstem program (module) that selects the next job to be admitted for exceution to CPU The main objective of scheduling is to inercase CPU uulisation ‘and higher throughput, Now-a-days, scheduling docs not matter much on simple PC's for following reasons BT case of PCs, most ofthe time there is only one process which is activ 50 the Ter does not have to do much work to figure ou DT 7 It which process to run, C Gi) Because of new processors and rapid chan much faster over the years that the CPU is r, 1 major sink of CPU cycles in the past take ge in technology computers h, ‘rely a scarce resource any more just a fe ave became Even compilations, aL most nowadays. W seconds cated a LA, EN hse Oa ae, | Borber et Ue Operating Syren 24 In case of high-end net-worked workstations and servers, multiple processes often do’ compete for the CPU, so scheduling matters very much in such cases, 2.9. oo Behaviour \— In mulliprogramming, several processes are active for efficient utilization of the CPU. Broadly, we classify processes into two categories : (1/0 bound ; As the name indicates, this activity required more active participation of VO devices. This type of processes normally read in, vast amount of data and perfrom very little computation and output large amount of information thus require less CPU attention. Pay slip gis an example of 1/0 bound program. CPU bound : As the name indicates, this activity make CPU_more busy. This type of processes need very little /O, but require heavy computations.) These processes require much CPU ‘time, as compared to 1/0 bound processes. A simulation program based on arithmetic calculation is an example of CPU bound. In multiprogramming, systems are designed in such a way, so that a proper mix of VO bound and CPU bound process is always there in memory. There are various scheduling queues as per details below : (200) (490) (500) (1000) In the details given below all the process are able to mect the deadlines prescribe before time OR 0 124 194 494 744 ao [ ee PL P3 Deadline —> (490) (200) (500) (100) However in 2nd option the deadlines are met with very less margin, thus Ist option wil be preferred. re Streategies in the earlicr part of the chapter that in Preemptive Strategies, th ity which depend upon arrival time, size ¢ cheduling under this category. We_have seen Suspension/preemption is allowed based on the priorit uum of all etc. We will discuss various a job, minim 2.1.2.1 Round Ri is scheduling method, CPU_time_is_allotted_on_round_robi \As the name ‘simplest and widely used algorithm, \The round robin schedulin fme-sharing and a multiuser system)where the primary requiremer algorithm is primarily us dina ti m is (@ provide reasonable good response times and in general to sharc the system fairly among @! system users. Each process is_assigned_a_time from 10 to 100_mscey To implement (FirstIn-First-Out)_queutoF processes —aad_new processes_are_added_t0_the end of the read qiicue. [fhe CPU scheduler selects the first process Trom the ready queue, sets a timer equal jime quantum for interrupt and dispatches the prgcess for executions It is ensured that_no proc time slice/quantum ier there arc other processes waiting i? a can run for more than one Tf a process require more CPU time to complete after exhausting one tim and range asa Fi terval, _known_as_quantum_or_time-s found robin, we keep the ready que ready queue. goes to the end of the ready queue to await the next allocation. If the process has blocked | ow completed before the quantum has elapsed, another fe is Scheduled to runs eee apogee Preemption after a quantum The Switching from one_process to another process requires a certain amount of time the jobs related tO administration, saving, loading régisters and -memory maps, updating va tabl reloading the memory cache ctcyLet all the activities related with process Switch or context owitch need milliseconds. If a quantum consists of 10 msec then after doing 10 msce of useful Work, the CPU will have to spend 1 msec on process. switchi “9% of the CPU time will be wasted on administrative overhead. To improve the CPU efficiency, one can set the quantum to, say, 50 msec, now the wasted time is only 2% but, it may cause poor response o short interactive requests. Thus a proper selection of time slice is important for a quantum. Time quantum around 20-50 msec is often a reasonable compromise. Round-Robin scheduling is often regarded as a fair scheduling method. It is also one of the best known scheduling method for achieving good and relatively evenly distributed response time. 2.11.22 Two Queue Scheduling \W_round robin, due to process switching a considerable ‘time of CPU_is wasted. As a | Solution, it was decided to” give CPU bound processes a Targe quantum once in a while, rather Than giving them small quantum/time-slices frequently response time. As a solution two queuc scheduling came into existence. In this approach, the distinction between jobs is made on their execution time or nature of jobs etc. One queue is alloted to 1/O bound jobs and other is alloted to CPU bound jobs. This is carried out to have a good mix of CPU & I/O bound jobs. Similarly, these queues can be based on foreground (intractive) processes and background (batch) process. These two types of processes have different response time requirement and thus have different scheduling needs. CPU-Bound Jobs —_——__—» | Highest Priority Queue | ————» or Foreground process 3 VO-Bound Jobs —— |_ Lowest Priority Queue or Background process | 2.1123 Multiple-level- )) Scheduling ' Solution to problems discussed above, concept of multiple-level-queue was Ips. ‘A multiple queue scheduling algorithm partitions the ready” queue into seperate queue, Process are permanently assigned to each queve, usually based upon priorities, such as size or process type. Each queue has its own scheduling algorithm, which may be preempting, non-preemptive, FCFS, SIF ctc. The interactive queue might bé scheduled by a round robiq algorithm while batch queue follows FCFS. In this type of scheduling, processes are, clasified Each queue is serviced by some scheduling method best suited to the type of processes stored in the queue. There are different possibilities to manage queues. One possiblility is (g assign a time slice to each queue, which it can schedule among different processes in its queue, Foreground processes can be assigned 65% of CPU whereas background processes are given 35% of the CPU time. q The second possibility is to set up priority classes. Processes in the highest class were Fun for one quantum whereas processes in the next highest class will run for two quanta and Processes in the next class will run for four quanta etc. Whenever a process used up all the quanta allocated to it, it is moved down one class, As an example, consider a process that needed to compute continuously for 200 quanta/time-slices. It would initially be given one'quantum, then swapped out, Next time it would get two quanta before being swapped out. On succeding runs it would get 4, 8, 16, 32 and 64 quanta, although it would have used only 37 of the final 64 quanta to complete its work. Onl 7 swaps would be needed (including the intitial load) instead of 200 with a pure round-robin algorithm. Also, as the process gets deeper and deeper into the priority queues, it would be run less and less frequently, saving the CPU for short, intractive processes. —-[Genrenee—]— ep A ee Lowest ———» Priority Highest Students Process Queue S) We can even have Multiple Queue ‘Feellback system, where the jobs keeps om shifting from one queue to another queue based on the feedback ic, Initially a job is CPU bound bet later it changes to 1/0 bound so it will change queue from CPU bound to 1/0 bound, ‘This approach is complicated and need heavy data structure in term of multiple queues, —— | cPUBound |——»> —— >| MixBouns = |———_> ——>| v0 Bound =| ——_» T Multifeedback Queues What advantages is there in having different time-quantum sizes on different levels of @ ~ multilevel queuing system ? 2. Explain the different states of Process. Draw! a Process State diagram, 3. Why the initialization of an OS is required. 4. Explain the process address space in detail. 5. Compare the CPU and I/O Burst cycle. Which is Burst is mandate for a program to execute, 7. What are different types of scheduling queues. 8. What do you mean by Process schedulers. List the different type of schedulers. Explain the FCFS scheduling mechanism with suitable example. Explain the Shortest Job First scheduling mechanism with suitable example. Why SJF leads to starvation. 10 12. Explain the Priority scheduling mechanism with suitable example, 13. Explain the deadline scheduling mechanism with suitable example, 14. What do you mean by Multi Level Queue Scheduling, Ri 15, What do you mean by foreground and background process ? 16, Describe about the life cycle of a process ? 17. What do you mean by resource abstraction ? 18. What do you mean by process abstraction ? 19. Explain in brief the procedure for initializing the operating system ? 20, What do you mean by process address space ? Explain compile time, load time and ray time, 21, What are the different data structures associated with the CPU scheduling ? 22, List different types of schedulers. 23. Do we always need to have medium term scheduler, if not, justify your answer. 24, What are the different criteria for measuring the performance of a scheduler ? 25. Explain in brief the non-primitive and primitive CPU scheduling. Explain short job firs scheduling. 26. Explain shortest remaining time next, 27. Why the decision on time is an important factor in round robin scheduling. 28. Describe the differences among short-term, medium-term and long-term scheduling. 29, Define the difference between preemptive and nonpreemptive scheduling. State why strict nonprcemptive scheduling is unlikely to be used in a computer center. 30. Consider the following set of processes, withthe length of the CPU-burst time given is milliseconds : Process Burst Time Priority Py 7 3 P2 1 1 P3 s, 3 Ps 2 4 Ps “ 2 The processes are assumed to have arrived in the order Pi, P2, Ps, Pa, Ps all at time 0 (a) Draw four Gantt charts illustrating the execution of these processes using FCFS, SJF a nonpreemptive priority (a smaller priority number implies a higher priority and RR (quantum =1) scheduling. ‘What is the turnaround time of cach process for cach of the scheduling algorithms in part a? (c) What is the waiting time of each process for cach of the scheduling algorithms | part a? (d) Which of the schedules in part a results in the minimal average waiting time (over all processes) ? . (b) : o SS ee cy ee... | 31. Suppose that the following processes arrive for execution at the times indicated, Bach Process will run the fisted amount of time. Using nonpreemptive scheduling Process Arrival Time Burst Time Py 0.0 10 Pa 04 5 Ps 10 z (a) What is the average turnaround time for these processes with the FCFS scheduling algorithm 2 (>) What is the average turnaround time for these processes with the SIF scheduling algorithm 2 Suppose that a scheduling algoritm (at the level of short-term CPU. scheduling) favors those processes that have used the least processor time in the recent past. Why will this algorithm favor /O bound programs and yet not permanently starve CPU-bound programs ? Explain the differences in the degree to which the following scheduling algorithms discriminate in fovour of short processes : (a) FCFS (b) RR (©) Multilevel feedback queues 33 Suppose three processes pi, p2 and p3 are attempting to use a machine with direct VO and interrupts concurrently. Suppose pl has tcompute =30 and tdevide =70, p2 has tcompute = 50 and tgcvice=15 and p3 has tcompute=25 and device =55. What is the minimum amount of time required to execute the three processes ? 35. Assume you have the following jobs to execute with one processor, with th jobs arriving in the order listed here : Process Burst_Time Pr 80 P2 30 P3 10 t Ps 30 ; Ps cy Using the SIN scheduling . (a) Create a Gantt chart illustraing the execution of these processes. (b) What is the turnaround time for process Ps ? (c) What is the average wait time for the processes ? Suppose a system uses priority scheduling (under the following process load), where & small integer means a high priority, w Process Burst Time Priority PL 80 3 ; . Pr 1 ; P3 10 4 Py 30 5 Ps 0 2 (a) Create a Gantt chart illustrating the execution of these processes. (b) What is the turnaround time for process p2 under priority scheduling ? i) (©) What is the average wait time for the processes ? 37. Assume you have the following jobs to execute with one processor : } Process Burst Time Arrival time t Py 15 0 Py 40 10 P3 25 10 ; Py 2» 80 Ps, 45 85 (A) Suppose a system uses RR scheduling with a quantum of 20. (a) Create a Gantt chart illustrating the execution of these processes. (b) What is the turnaround time for process pl ? | (c) What is the average wait time for the processes ? } (B) Assume the context switch time is five time units with RR_ scheduling. (a) Create a Gantt chart illustrating the execution of these processes. (b) What is the turnaround time for process p3 ? (c) What is the average wait time for the processes ? 38. Assume you have the following jobs to execute with one processor. Process Burst Time _ Priority Pi 70 a P2 200 4 P3 10 3 Py 15 2 Ps 40 1 The jobs are assumed to arrive at the same time. Using priority scheduling, execute th following, : (a) Create a Gantt chart illustrating the execution of these processes. (b) What is the turnaround time for process pi ? (c) What is the average wait time for the processes ? = = Tie 4 39. What are the types of information, expected with arrival order of requests in CPU scheduling ? 40. What do you mean by CPU bound and I/O bound jobs. Give are cxample of cach job. 41, Explain why two level scheduling is generally used ? bjective Type Questions : 1. Process is— (a) Programme (b)- Programme under execution (c) Programme already completed (d) None of the above 2. Process Manager is responsible for— (a) scheduling of process (b) synchronization (c) deadlock handling (d)_all of above 3. Data structure which keeps details related with state of the process is called as— (a) process abstractor (b) process descriptor (©) process status (d) programme descriptor 4. The various stages in which the process can be, are— (a) new, ready (b) new, ready, terminated (©) new, ready, running, terminated (d)-néw, ready, running, waiting, terminated S. PCB has bare minimum value in (a) new state (b) terminated state (0) ready state (4) wait state 6. Example of re-usable resources are— (a) printer {b)-printer, hard disk (©) paper . (a) none of above 7. CPU bound job will have more— (a) 10 burst AbYCPU burst (c) both (@) none of above 8. In execution of any task minimum ... . following’ is essential — (a) CPU burst (b) CPU burst followed by 1/0 burst (c) VO burst (d) none of above 9. Example of /O bound job is— (a) Printing of pay slips of a large organisation (b) Arithmetic calculation (c) Simulation programme. (d) None of the above 10. The various queues are— (a) job queue (b) ready queue device queue (©- job queue, ready queue device queue — (d) none of above LL. The type of schedulers are~ (a) long term scheduler (c) medium term scheduler 12. Long term scheduler is also called as— (a) Memory scheduler (b) short term scheduler _{d)-all of above (b) CPU scheduler (0) Tob scheduler (d) none of above 13. Medium term scheduler is also called as— _{) Memory scheduler (b) CPU scheduler (©) Job scheduler (a) None of above 14. Short term scheduler is also called as— (a) Memory scheduler _(b)_CPU scheduler (c) Job scheduler (d) none of above 15. The scheduler which decides the degree of multi- porogramming, is— (a) medium term scheduler (b) short term scheduler (c)Tong term scheduler (d) all the above 16. The Scheduler which decides the execution time of a process is— (a) medium term scheduler _—-¢b)-short term scheduler (c) long term scheduler (d) all the above 17. Throughput of an operating system is— (a) average time taken for completion of job (b) time taken for job submission (c)-tumber of programs executed in a unit of time (d) none of above Is. Scheduling mechanism can be divided into— (a) primitive category (b) non-primitive category fora) and (b) both (d) none of above 19, First Come First Served (FCFS) scheduling is— (a) primitive type A Unable to allocate int Compact space and update tables accordingly The advantages of this pelieme Arey 1, £liminate Fragmentation to some exteht, 2. Results into higher degree of multiprogramming. The disadvantages of this scheme are 1. The compact time is substained, 2. The Reallocation Hardware increase cost, 3. The “Complexity ' in development. 4. Still ‘Some memory is wasted. oe i ‘Allocate partition Aeshna J tri a 08 Bupdate table Menory Menagement 00 This scheme can be explained with example, Let us consider the job queue for a system as follow = eae oe sank ea sae = a aad oa faut ‘System System em ‘System a eal re ood a eer : 7 ri }200K 1200K ‘ 0x = aaa ad ° 8 8 B fee oor sn c Extemal ce Ee coal a oe Cr om as 1 2 3 4 5 EA Wastace Here we have considered round robin scheduling with quatum of 2 units. From this we sec that memory suffers from fragmentation. This fragmentation can be external fragmentation or internal fragmentation. The external fragmentation exists when enough total memory space exists to satisfy a request, but is not contiguous, the memory space is broken into a large number of small holes. If we sce figure, at position 1 we find that external fragmentation of 200K exists which can not satisfy any request. However there is possibility that fragmentation may exist and when summed up, it may be more than the size of the job in pending queue. Sometimes, situation arises when small, hole exist in the partition. This generally arises when partition size is slightly more than the job size: If we see Fig. at position 3, we find that internal fragmentation of 100 K exist for partition where D job is residing. The external fragmentation can be minimised by compactation ic. to keep all the free space in continuation whereas internal fragmentation will always exist. For allocating memory space (partition) to a job, there are different algorithms. The common algorithms are 1. First fit 2. Best fit 3. Worst fit First Fit’: In this scheme of allocating partition to a job, the available Space jg sorted by location, The first hole available is simple to implement and favours fr Best Fit : In this scheme, tha table big enough to accomodate the job is available, it is allotted to it. It has been observed that table. This scheme can fan average, best fit area can be found by scarching only half the in less wastage of memory, hole to a job. This result in large wastages of memory can be allotted, 45.4 Contemporary Alloc mn Strategies Now a days, all memory managers use memory is generally allocated in fixed blocks list. In carlicr systems like UNIX- size of blocks. In these systems, whenever a method like best fit, first fit, worst fit, etc. to of process increases, it request and release m of execution. It has been observed that the for changes, because the address space, which change size, whereas the space assigned for and process state. In case, if the part of the space th Program is being unloaded from memory or the program is does not happen in many languages. means that loader must rebind cach a It is to be mentioned that the adjusting of that for program, because it does not need 4.6 Dynamic Address Re-location In general, symbols in source program module at a compile time and then to Programmer to take special ssily change the ,memory to a process will pace, which is using the memory. This ap dynamic re-locations Let us tak 0 as to match the physical memory. Since addresses in absolute module at to suit to the size of job is allotted to job, ree areas at low memory address, whenever is kept sorted by size and whenever, the ize and allocate the memory but if we have small size job, then one oF other form of variable partitioning. Howey and thus results into simply:the management of fg 0 or DOS, the memory management was based on variabl Process is created, the memory manager uses th assign an initial amount of memory. As the progres emory according to its need for amy particular pha Part of address space, which contain data, is liabe has been assigned for the program will not normal data will change size depending upon type of dit at contains program, grows then cither part of th somehow growing. Generally, hi However, this happen mainly in language like LISP. Thi iddress in the program to the new p ry memory locatio binding of address for data handled casily that to have address re-allocation, are first bound to relative addresses in a re-locatabl © Program around in the memory without requiring action to compensate for the re-location, With this approach we bout re-locating the process ackires because of its dynamic nature is called # hout thinking al proach, algorithm with the loader uses to adjust addresses in the absolute. moduk he absolute module is built as if it is to be le at memory location 0, add module, Now, when the loader determ 1 0 it can adjust any relative address by addi See it, The reallocation is generally used, in contemporary cama of any management strategy. The various approaches are as follows: 1, The re-allocation register value, which is a part of processes state is added to the generated address to get the actual physical address. 2. The content of code register, strike register, data register, ete. are added to the generated address to result into actual physical address. 3. Suppose the compiler generates normal 16 bit addresses when it Mia a source: module and leaves external references to be handled by linkage editor. If function is executed in a module, the initialization code at the entry point loads the code and data segment register, to bind to the part of absolute imaged corresponding to the re-locatable module. When control flows from one module to another module the calling function will reference an external symbol, that will later will be resolved by linkage editor. This technique is based on the compiler and the linkage editor to provide large enough address space through manipulation of the segment register. This scheme is not suitable for assembly language program or program tanga en segment register value. 4.7. Memory Manager Strategies fi 2 proeram i has 1oobe-semale meno A Program which is executed is to be renioved from main memory and other program is required To 27 Removing suspended on preempted processes from memory and their subsequent Emenee -S.called swapping Swapping has traditionally been used to implement with restrictive memory capacity Swapping requires a secondary storage. The eee storage (generally a fast disk) must be large cnough to accomodate copies of all memory images for all users and must provide direct access to these memory images. The system maintains a ready queue consisting of all processes whose memory images are onthe backing storage or in memory and are ready to run. When the schedular decides to admit a new process for which no suitable free en ‘an be found, the swapper may be invoked to vacate such a partition. The swapper is *Perating-system process whose main responsibilities include + Selection of processes to_swapoul, Selection of processes to swap in Allocation and n nagement of swap space Primary Storage ‘Swapping of A & B process using Hard Disk Initially only process P1 is in memory. Then processes P2 and P3 are created or in from the disk. Process P1 is swapped out to disk. Then process P4 comes in and goes out. Finally, Process Pl comes in again. Since process P1 is now at a different addresses contained in it must be relocated, either by software when it is swapped hardwae during program execution, The ¢ jn for a program depends upon the method of ‘of assembly or load time, then process cannot be done at execution time then process can move to new Swapping also called as roll out, roll fn. techniques. memory-management systems with contiguous allocation, such as fixed and "shames pratdes memory and segmentation. The choice of the process to swap in is usually based on the amount of time it spent on secondary storage (age.) priority and satisfaction of the minimum swapped out disk residence time requirement, which is imposed to control thrashing. wes Currently, standard swapping is used in few systems. It requires too much swapping time, and provides (oo little execution time to be a reasonable memory-management solution. Modified versions of swapping, however, arc found on many systems. An example is the Microsoft- windows operating system which supports concurrent execution of processes in memory. If a new process is loaded and there is insufficient main memory, an old process is swapped to disk. The operating system, however, docs not provide full swapping because the schedular decide when it is time to swap one process for another. 412 Virtual Memory ~~ it The commn problem before into the smi Gverlays (he other overlays are executed in same way. The overlays used to be on hard disk and swapped in and out of memory being decided by Operating System. . Virtual_memory, was devised by Forthering ham in 1961. Virtual memory %& a mem@ry-management scheme where only a protion of the virtual address space of a “resident” process may actually be loaded into memory. In other words, virtual allows _ execution of partially loaded» processes. Thus we can sah tat Grea meee is ecbeigoe teal oe hat_allows the-txeeution oF processes that may not be completely . The main visible advantages -ol-this-scheme is shat programs can be Targer than physical memory. As a consequence, the sum of the virtual address spaces of active processes in a virtual-memory system can exceed the capacity of the available memory provided that the memory is large enough to hold a minimum amount of the address space of cach active process. Thus, where as the real-memory schemes strive to 4pproach 100% utilization of memory. Virtual memory scheme routinely provide utilization factors of 100% The, basic idea behind virtual memory is that the combined size of the program, dats and . ‘ack may exceed the amount of physical memory. The operating system keeps those parts of the ouram in the memory which are required during the execution and the others (balance) remain plc, a 2 MB program can run on a 640 K RAM machine by carefully ing (40 K to keep in memory at each instant and swapping pieces of a program between tisk and me ory as needed. " the disk, For exa ox

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy