10、单选 在页式虚拟存储器中,页面大小4KB,用户空间共16个页面,其中0、1、2、3、4页已装入主存,分别对应的物理块号是2、9、5、6、1,则虚拟地址3A5BH对应的物理地址是_______。 (5分) A 6A5BH B 9A5BH C 9A5BH D 2A5BH
时间: 2023-10-20 08:32:46 浏览: 50
首先,页面大小为 4KB,即 $2^{12}$ B,因此一个页面可包含 $2^{12}$ 个字节。虚拟地址 3A5BH 对应的页号为 3A5Bh/4096 = 0Ah,对应的页内偏移量为 3A5Bh mod 4096 = 3A5Bh - 0Ah * 4096 = 15BH。由于页面大小为 4KB,即 $2^{12}$ B,因此页内偏移量需要用 12 位二进制数来表示。
根据题意,页号为 0、1、2、3、4 的页面已经在主存中,因此虚拟页号为 0Ah 的页面需要从磁盘中读入。根据题意,页号为 0Ah 对应的物理块号为 2,因此需要将磁盘上的页面读入到物理块号为 2 的物理内存中。
因此,虚拟地址 3A5BH 对应的物理地址为:物理块号为 2,页内偏移量为 15BH,即 2*4096+15BH = 9A5BH。
因此,答案为 B。
相关问题
在Android中实现从一个页面单选性别和多选课程后,把数据传到另一个页面
在Android中实现从一个页面单选性别和多选课程后,把数据传到另一个页面可以通过以下步骤实现:
1. 在第一个页面中,定义性别和课程的单选和多选控件,例如RadioButton和CheckBox。
2. 在第一个页面中,添加一个“提交”按钮,当用户点击该按钮时,获取所选的性别和课程信息,并将其打包成一个Bundle对象。
3. 在第一个页面中,使用Intent对象跳转到第二个页面,并将打包好的Bundle对象添加到Intent中。
4. 在第二个页面中,获取Intent对象,并从中获取打包好的Bundle对象。
5. 在第二个页面中,解析Bundle对象,获取所选的性别和课程信息,然后将其显示在页面上。
以下是示例代码:
第一个页面:
```
public class FirstActivity extends AppCompatActivity {
private RadioGroup mGenderRadioGroup;
private CheckBox mMathCheckBox;
private CheckBox mEnglishCheckBox;
private CheckBox mScienceCheckBox;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_first);
mGenderRadioGroup = findViewById(R.id.gender_radio_group);
mMathCheckBox = findViewById(R.id.math_checkbox);
mEnglishCheckBox = findViewById(R.id.english_checkbox);
mScienceCheckBox = findViewById(R.id.science_checkbox);
Button submitButton = findViewById(R.id.submit_button);
submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int genderRadioButtonId = mGenderRadioGroup.getCheckedRadioButtonId();
String gender = "";
switch (genderRadioButtonId) {
case R.id.male_radio_button:
gender = "Male";
break;
case R.id.female_radio_button:
gender = "Female";
break;
}
ArrayList<String> courses = new ArrayList<>();
if (mMathCheckBox.isChecked()) {
courses.add("Math");
}
if (mEnglishCheckBox.isChecked()) {
courses.add("English");
}
if (mScienceCheckBox.isChecked()) {
courses.add("Science");
}
Bundle bundle = new Bundle();
bundle.putString("gender", gender);
bundle.putStringArrayList("courses", courses);
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
intent.putExtras(bundle);
startActivity(intent);
}
});
}
}
```
第二个页面:
```
public class SecondActivity extends AppCompatActivity {
private TextView mGenderTextView;
private TextView mCoursesTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
mGenderTextView = findViewById(R.id.gender_text_view);
mCoursesTextView = findViewById(R.id.courses_text_view);
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
String gender = bundle.getString("gender");
ArrayList<String> courses = bundle.getStringArrayList("courses");
mGenderTextView.setText(gender);
mCoursesTextView.setText(TextUtils.join(", ", courses));
}
}
}
```
MyEclipse编写一个页面输出单选试题,再编写一个信息处理页面获取用户做出的选择,并统计得分
好的,我可以为您提供一个简单的 MyEclipse Web 程序,用于输出单选试题,并处理用户的选择并统计得分。以下是示例代码:
1. 单选试题页面(single_choice_question.jsp)
```jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Single Choice Question</title>
</head>
<body>
<form action="score.jsp" method="post">
<p>1. What is the capital city of France?</p>
<p><input type="radio" name="answer" value="A"> A. London</p>
<p><input type="radio" name="answer" value="B"> B. Paris</p>
<p><input type="radio" name="answer" value="C"> C. Madrid</p>
<p><input type="radio" name="answer" value="D"> D. Berlin</p>
<input type="submit" value="Submit">
</form>
</body>
</html>
```
2. 信息处理页面(score.jsp)
```jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Score</title>
</head>
<body>
<h1>Result:</h1>
<%
String answer = "B";
String selectedAnswer = request.getParameter("answer");
if (selectedAnswer != null && selectedAnswer.equals(answer)) {
out.println("<p>Your answer is correct!</p>");
} else {
out.println("<p>Your answer is incorrect. The correct answer is " + answer + ".</p>");
}
%>
</body>
</html>
```
这个程序包含两个 JSP 页面:一个用于输出单选试题,另一个用于处理用户的选择并统计得分。
在单选试题页面中,它生成一个包含试题和选项的 HTML 表单,用户可以在这个表单中选择答案,并提交到信息处理页面中进行处理。
在信息处理页面中,它获取用户选择的答案,并与正确答案进行比较,输出用户的得分。
您可以将这个程序打包成一个 WAR 文件,然后将它部署到一个 Java Web 服务器上,如 Tomcat 或 Jetty。当用户访问单选试题页面的 URL 时,它就会输出单选试题的页面。当用户提交答案后,它会跳转到信息处理页面,并输出用户的得分。