In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to realize the page replacement algorithm in C language". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "C language how to achieve page replacement algorithm" it!
1. Realize the effect
two。 Implement source code # include#include#include#include#include#include#includeusing namespace std # define Myprintf printf ("|-- +-- +-- |\ n") / * Table control * / # define bsize 4 / / physical block size # define psize 16 / / process size void chushihua (); / / initialization function void ymzh (); void yemianzhihuan () Void changeaddr (struct Page p [], int logaddr); void dizhizhuanhuan (); void menu (); int wang (); int yemianliu [32] = {0}; / / Global variable array, address stream int p; struct Page {int pno;// page number int flag;// flag bit int cno;// main memory number int modf;// modification bit int addr;// external memory address} Page / / the global variable p is the total number of address streams typedef struct pagel {int num; / * record page number * / int time; / * record memory time * /} Pagel; / * page logic structure to facilitate algorithm implementation of * / Pagel b [bsize]; / * number of memory cells * / int c [bsize] [psize]; / * keep the current state of memory: buffer * / int queue [100] / * record call to queue * / int kPlachap * call queue count variable * / int phb [bsize] = {0}; / physical block label int pro [psize] = {0}; / enter program column number int flag [bsize] = {0}; / / number of process waits (process flag that has not been used for the longest time) * / int iB0t flag I represents the process sequence number, j represents the physical block number * / int m =-1, n =-1 / / physical block idle and process are the same judgment flag * / int mmax=-1, maxflag=0;// tag replaces physical block process subscript * / int count = 0 scramble / statistics page page missing times void chushihua () / / initialization function {int t; srand (time (0)); / / randomly generate instruction sequence p=12+rand ()% 32; cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.