Вы находитесь на странице: 1из 5

Swapping is a simple memory/process management technique used by the operating system(os) to increase the utilization of the processor by moving

some blocked process from the main memory to the secondary memory(hard disk);thus forming a queue of temporarily suspended process and the execution continues with the newly arrived process. After performing the swapping process, the operating system has two options in selecting a process for execution : *Operating System can admit newly created process (OR) *operating system can activate suspended process from the swap memory. Swapping is used when there is not enough memory to hold all the processes that want to run. In swapping processes that have been blocked or descheduled are swapped out to disk to make room for other ones that want to run. When it is their turn to run again, they can be swapped into the memory. The method of dynamically moving processes between memory and disk is called swapping. Partitions in swapping do not have to be fixed. One problem that arises as a result of swapping with variable-sized partitions is the creation of holes in

memory. Holes are areas of unused memory between partitions. They are usually too small to hold a process and too scattered out to be of any use whatsoever.

The solution is to combine all the holes together, allowing a process to move into that space on the next cycle. This technique is called memory compaction. Since memory compaction has a large overhead (takes a considerable amount of time to complete), various other algorithms are used by the memory manager to allocate processes to holes. Here if the processes data segment can grow ( ie. By dynamically allocating memory ), as in many programming languages, a problem occurs when a process tries to grow. If a hole is adjacent to process, it can be allocated and the process is

allowed to grow into the hole. On the other hand , if the process is adjacent to another process, the growing process will either have to be moved to a hole in memory large enough for it or one or more process will have to be swapped out to create a large enough hole. If a process can not grow in memory and the swap area on disk is full, the process will have to suspend until some space is freed up. If it is expected that most processes will grow as they run, it is probaqbly a good idea to allocate a little extra memory whenever a process is swapped in or moved, to reduce the overhead associated with moving or swapping processes that no longer fit in their allocated memory. However, when swapping processes to disk, only memory that is actually in use should be swapped; it is wasteful to swap the extra memory as well.

In this figure we see that each process allocated has a tsack at the top of its allocated memory that is growing downward, and a data segment just beyond the program text segment that is growing upward. The memory between them can be used for either segment. If it runs out, the process will either have to be moved to a hole with sufficient space,

swapped out of memory until a large hole can be created, or killed.

Вам также может понравиться