How to determine page references in memory management - operating-system

I know how to use page references to determine a page fault using FIFO. I was confused if how to determine if we have FIFO table.
A process consists of six pages, 0 1 2 3 4 5. Page 0 is automatically loaded when we start running the program. Other pages are loaded (as they are referenced) by the page fault mechanism. This process is allowed only 3 pages in memory at any one time.
How to get a sequence of page references that this process can make (starting with 0, 2, 4)? Asterisks represent page faults.
enter image description here

Related

How should modified pages be written out to secondary memory using Page Buffering?

I am studying for my final OS exam and am currently stuck in a question:
Assume a system uses demand paging as its fetch policy.
The resident size is 2 pages.
Replacement policy is Least Recently Used (LRU).
Initial free frame list: 10, 20. 30, 40, 50
Assume a program runs with the following sequence of page references:
3(read), 2(read), 3(write), 1(write), 1(write), 0(write), 3(read)
I am asked to show the final contents of the free frame list, modified list, and the page table.
Here is the model answer.
This is what I managed to do.
The final Resident Set is correct, but the free frame list and the modified list are not. I just cannot see how the modified list does not contain page number 0 (as in it got written to memory), while page number 1 was not written even though it was referenced before it.
Any help would be appreciated.
Why do you recycle 3(10) to the free list in step 4? It was the least recently used (and is dirty) so you would want to keep it, and get rid of 2(20). That appears to be what the model answer is based on.

Can a memcache page change slab class?

I'm trying to understand how memcached memory model works.
If all items in an assigned page have expired or been deleted, can that page be marked as unassigned (and later migrate to another slab class)? That is, let's say I fill up my memcached instance with lots of 1 kb objects with an expiry of 24 hours. 48 hours later, I write lots of 512 kb items (different slab class), will the 1 kb slab class pages slowly get unassigned?
If this is the case, best practise should be to always set an expiry time for all objects.
I did some tests on 1.4.20 (starting the app without any flags) and can confirm that within the ~5 minutes I ran the tests, pages did not change slab classes.
Above said, there is something called automover which is a background thread that automatically can change the slab class for pages as they turn unused.

Start add2ress of the page in memory?

If a process references the virtual address 0x100F3557, the values of the three fields, in which the virtual address can be splitted, are:
Offset = 0x557
Page Table = 0x0F3
Page Directory = 0x040
The Page Table Entry of this address has the value 0x71248021.
What is my start address of the page in memory?
Assuming x86 paging the page table entry consist of the (physical) address of the frame the page is mapped into plus some control information. The later occupies the lower 12 bit of the entry, which are the last 3 digits of your hexadecimal value. Thus
frame address = 0x71248000
control information = 0x021
The control information here tells us that this page is
present, bit 0 set, thus there is an active mapping.
read-only, bit 1 unset
user mode accessible, bit 2 unset
(write back cached, bit 3 unset)
(cached, bit 4 unset)
accessed, but not written to (bit 5 set, bit 6 unset)
(not a global page, bit 8 unset)
Thus, assuming a read operation, the process will access address 0x71248000 | 0x557 == 0x71248557, with 0x557 being the offset extracted from the virtual address.

Popularity of each wikipedia article

I would like to store a list of all en.wikipedia articles in my database. For each article I want to store the pageid, title and the popularity. I thought about using the view count (over the last month) as a measurement for popularity but if that is not possible, I could imagine going for something else (maybe use the number of revisions). I'm aware of http://dumps.wikimedia.org/enwiki/latest/ and that I can get a full list of articles from there (current count 36508337). However, I can not find a clever way to get the view count for each article.
// Updates, Edits, ...
The suggested duplicate does not help me because
a) I was looking for a popularity measurement. The answer to the other questions just states that it is not possible to get the number of watchers for a page, which is fine with me.
b) There is no answer there that gives me the page views (or any other metric) for every page.
Okay I'm finally done. Here is what I did:
I found http://dumps.wikimedia.org/other/pagecounts-ez/ which provides page views per month. This seems promising but they don't mention the pageid so what I'm doing is getting a list of all articles from http://dumps.wikimedia.org/enwiki/latest/, create a mapping name->pageid and then parse the pagecount dump. This takes about 30 minutes, here are some statistics:
68% of the articles in the page count file do not exist in the latest dump. This is probably due to some users linking, for example, Misfits_(TV_series) while other link to Misfits_(tv_series) and even stuff like Misfits_%28TV_series%29... I did not bother with those because my program already took long enough to run.
The top 3 pages are:
2.1. Front page with 639 million views (in the last month)
2.2. Malware with 8.5 million views
2.3. Falcon 9 v1.1 with 4.7 million views (cool!)
I made a histogram for the number of pages with a certain view count, here it is:
I also plotted the number of pages I would have to deal with when I disregard all articles below a certain view count. Here it is:

Handling From and To Range Field Values

Say for example I am getting a range of integers from a user:
Generate between nnn and nnn widgets.
Yes, most users will ensure that the first number is equal to or less than the second number:
Generate between 3 and 7 widgets.
But then there's that user, who wants to enter this data "back to front";
Generate between 7 and 3 widgets.
Do you quietly switch the fields around when the user clicks OK/Apply so, in the example above, you change the range of 7 to 3 back to 3 to 7 in the GUI? This might not be so practical on a web form where the user enters some data and then submits the form never to see it again but I'm thinking more in terms of a desktop application's settings page where the user's input is saved and subsequently viewed and edited again by the user.
Is it more important to try and educate users to enter a range that "makes sense" via error/alert messages, or quietly cajole their entries into the shape an application is expecting?
I suspect the "cajoling option" is more preferable, but could this "hey the program messed with my data!" approach be a problem for users?
I am currently writing an application that has a handful of these user-configurable ranges so I'm very interested to follow the general consensus of the SO experts.
If the user enters data incorrectly you shouldn't assume a particular pattern of error and automatically correct it. Either report the error to the user and ask them to correct it or suggest a correction that they can approve. In your example, what if the user intended to type 7 and 13 but simply mistyped. If you changed it to 3 and 7 you've entered incorrect data without the user's knowledge. I'd probably do the simple thing and use a visual alert when incorrect data is entered (but before it's actually submitted) and refuse to accept incorrect data, returning an error if it is submitted incorrectly.