Skip to main content

What are concept of physical address, logical address, and virtual memory in Java ? What are the page replacement algorithms in Java? What are dynamic link libraries and static link libraries in Java?

 What are concept of physical address, logical address, and virtual memory in Java ?

1. Physical address: It is the final address of the address conversion. When the process executes instructions and accesses data when it is running, it must be accessed from the main memory through the physical address. It is the real address of the memory unit.

2. Logical address: refers to the address seen by computer users. For example: when creating an integer array with a length of 100, the operating system returns a logically continuous space: the pointer points to the memory address of the first element of the array. Since the size of the integer element is 4 bytes, the address of the second element is the starting address plus 4, and so on. In fact, the logical address is not necessarily the real address where the element is stored, that is, the physical address of the array element (the location in the memory bar). It is not continuous, but the operating system maps the logical address into continuous through address mapping. Yes, this is more in line with people's intuitive thinking.

3. Virtual memory: It is a technology of computer system memory management. It makes the application think that it has continuous available memory (a continuous and complete address space), but in fact, it is usually divided into multiple physical memory fragments, and some are temporarily stored on external disk storage. Data exchange at the time.

What are the page replacement algorithms in Java?

Request paging, also known as on-demand paging, means that "pages" that are not in the memory are called in when the process is executed, otherwise it may not be called in until the end of the program. The space reserved for pages in memory is limited, and pages are placed in memory in units of frames. In order to prevent excessive memory page faults in the process of requesting paging (that is, the required page is not currently in memory, data needs to be read from the hard disk, that is, page replacement is required) and the efficiency of program execution is reduced, we need to design some Page replacement algorithm, when pages are replaced with each other according to these algorithms, the error rate can be as low as possible. Commonly used page replacement algorithms are as follows:


First-in-first-out replacement algorithm (FIFO)

First-in-first-out, that is, eliminate the page that was imported first.


Optimal Replacement Algorithm (OPT)

Selecting the pages that will be used farthest in the future is an optimal solution, and it can prove that the number of missing pages is the smallest.


The least recently used (LRU) algorithm

That is, the page that has not been used the most recently is selected to be eliminated


Clock replacement algorithm

The clock replacement algorithm is also called NRU (Not Recently Used). The algorithm sets an access bit for each page, and links all pages in the memory into a circular queue through the link pointer.


What are dynamic link libraries and static link libraries in Java?


Static linking is to directly copy the required execution code to the calling place when compiling and linking. The advantage is that the dependent library is not needed when the program is released, that is, it is no longer necessary to release the library together, and the program can be executed independently, but the size It may be relatively large.

Dynamic linking means that the executable code is not copied directly when compiling, but a series of symbols and parameters are recorded, and the information is passed to the operating system when the program is running or loading. The operating system is responsible for loading the required dynamic library into the memory. And then when the program runs to the specified code, it shares the executable code of the dynamic library that has been loaded in the execution memory, and finally achieves the purpose of runtime connection. The advantage is that multiple programs can share the same piece of code without storing multiple copies on the disk. The disadvantage is that because it is loaded at runtime, it may affect the performance of the program's early execution.


Comments

Popular posts from this blog

Defination of the essential properties of operating systems

Define the essential properties of the following types of operating sys-tems:  Batch  Interactive  Time sharing  Real time  Network  Parallel  Distributed  Clustered  Handheld ANSWERS: a. Batch processing:-   Jobs with similar needs are batched together and run through the computer as a group by an operator or automatic job sequencer. Performance is increased by attempting to keep CPU and I/O devices busy at all times through buffering, off-line operation, spooling, and multi-programming. Batch is good for executing large jobs that need little interaction; it can be submitted and picked up later. b. Interactive System:-   This system is composed of many short transactions where the results of the next transaction may be unpredictable. Response time needs to be short (seconds) since the user submits and waits for the result. c. Time sharing:-   This systems uses CPU scheduling and multipro-gramming to provide economical interactive use of a system. The CPU switches rapidl

What is a Fair lock in multithreading?

  Photo by  João Jesus  from  Pexels In Java, there is a class ReentrantLock that is used for implementing Fair lock. This class accepts optional parameter fairness.  When fairness is set to true, the RenentrantLock will give access to the longest waiting thread.  The most popular use of Fair lock is in avoiding thread starvation.  Since longest waiting threads are always given priority in case of contention, no thread can starve.  The downside of Fair lock is the low throughput of the program.  Since low priority or slow threads are getting locks multiple times, it leads to slower execution of a program. The only exception to a Fair lock is tryLock() method of ReentrantLock.  This method does not honor the value of the fairness parameter.