Main.cc

//引导代码初始化操作系统内核。允许直接调用内部操作系统功能,简化调试和测试。在实践中,bootstrap代码只会初始化数据结构,

//并启动一个用户程序来打印登录提示。//许多内容只有在分配之后才是需要的。
(比如说在线程管理中,我们只定义了THREAD,这样文件系统等相关信息就不会被执行)

// Usage: nachos -d <debugflags> -rs <random seed #>
//  -s -x <nachos file> -c <consoleIn> <consoleOut>
//  -f -cp <unix file> <nachos file>
//  -p <nachos file> -r <nachos file> -l -D -t
//              -n <network reliability> -m <machine id>
//              -o <other machine id>
//              -z
//
//    -d causes certain debugging messages to be printed (cf. utility.h)
//    -rs causes Yield to occur at random (but repeatable) spots
//    -z prints the copyright message
//
//  USER_PROGRAM
//    -s causes user programs to be executed in single-step mode
//    -x runs a user program
//    -c tests the con

-d  与调试信息相关,如果执行时增加参数 -d -t 则是打印出和thread相关的调试信息,如果执行时增加参数 -d + 则打印出所有调试信息。否则不打印。
-d  所跟的参数代表了需要打印哪些相关参数(具体见utility.h)
-rs 在指定的范围内随机触发线程的Yield方法,让出cpu,这个范围就是-rs 之后跟的参数(个人理解,不一定对)
-z  打印版本信息

之后都是与 USER_PROGRAM,FILESYS,NETWORK相关的内容,现在先不考虑

//  FILESYS
//    -f causes the physical disk to be formatted
//    -cp copies a file from UNIX to Nachos
//    -p prints a Nachos file to stdout
//    -r removes a Nachos file from the file system
//    -l lists the contents of the Nachos directory
//    -D prints the contents of the entire file system
//    -t tests the performance of the Nachos file system
//
//  NETWORK
//    -n sets the network reliability
//    -m sets this machine's host id (needed for the network)
//    -o runs a simple test of the Nachos network software
//
//  NOTE -- flags are ignored until the relevant assignment.
//  Some of the flags are interpreted here; some in system.cc.
//
// Copyright (c) 1992-1993 The Regents of the University of California.
// All rights reserved.  See copyright.h for copyright notice and limitation
// of liability and disclaimer of warranty provisions.

#define MAIN
#include "copyright.h"
#undef MAIN #include "utility.h"
#include "system.h" #ifdef THREADS
extern int testnum;
#endif // External functions used by this file extern void ThreadTest(void), Copy(char *unixFile, char *nachosFile);
extern void Print(char *file), PerformanceTest(void);
extern void StartProcess(char *file), ConsoleTest(char *in, char *out);
extern void MailTest(int networkID);

#ifdef THREADS
extern int testnum;
#endif
由于现在分析的是线程管理过程,我们在Makefile中只定义了THREADS
DEFINES = -DTHREADS
所以将会定义参数testnum,用来记录测试的线程数。
在额外函数中,我们只调用了如下函数,该函数在threadtest.cc 文件中,执行一个线程测试。
extern void ThreadTest(void)

//----------------------------------------------------------------------
// main
// Bootstrap the operating system kernel.
//
// Check command line arguments
// Initialize data structures
// (optionally) Call test procedure
//
// "argc" is the number of command line arguments (including the name of the command) -- ex: "nachos -d +" -> argc = 3
// "argv " is an array of strings, one for each command line argument ex: "nachos -d +" -> argv = {"nachos", "-d", "+"}
//----------------------------------------------------------------------

 

int
main(int argc, char **argv)
{
int argCount; // the number of arguments
// for a particular command DEBUG('t', "Entering main");
(void) Initialize(argc, argv); #ifdef THREADS
for (argc--, argv++; argc > ; argc -= argCount, argv += argCount) {
argCount = ;
switch (argv[][]) {
case 'q':
testnum = atoi(argv[]);
argCount++;
break;
default:
testnum = ;
break;
}
} ThreadTest();
#endif

nachos3.4 threads管理 (c++)的更多相关文章

  1. Nachos-Lab3-同步与互斥机制模块实现

    源码获取 https://github.com/icoty/nachos-3.4-Lab 内容一:总体概述 本实习希望通过修改Nachos系统平台的底层源代码,达到"扩展同步机制,实现同步互 ...

  2. Nachos-Lab2-线程调度模块实现

    源码获取 https://github.com/icoty/nachos-3.4-Lab 内容一:总体概述 本实习希望通过修改Nachos系统平台的底层源代码,达到"扩展调度算法" ...

  3. Android 性能优化(16)线程优化:Creating a Manager for Multiple Threads 如何创建一个线程池管理类

    Creating a Manager for Multiple Threads 1.You should also read Processes and Threads The previous le ...

  4. State Threads之co-routine的创建和stack的管理

    1. 综述 协程库 State Threads Library 是一个基于 setjmp/longjmp 实现的 C 语言版用户线程库或协程库(user level thread). 基本协程例子: ...

  5. Android线程管理之ThreadLocal理解及应用场景

    前言: 最近在学习总结Android的动画效果,当学到Android属性动画的时候大致看了下源代码,里面的AnimationHandler存取使用了ThreadLocal,激起了我很大的好奇心以及兴趣 ...

  6. Openfire的启动过程与session管理

    说明   本文源码基于Openfire4.0.2.   Openfire的启动       Openfire的启动过程非常的简单,通过一个入口初始化lib目录下的openfire.jar包,并启动一个 ...

  7. Atomikos实现多数据源的事物管理

    之前试过使用Spring动态切换数据库,通过继承AbstractRoutingDataSource重写determineCurrentLookupKey()方法,来决定使用那个数据库.在开启事务之前, ...

  8. Unity游戏开发中的内存管理_资料

    内存是手游的硬伤——Unity游戏Mono内存管理及泄漏http://wetest.qq.com/lab/view/135.html 深入浅出再谈Unity内存泄漏http://wetest.qq.c ...

  9. [MySQL]MySQL之权限管理

    一.MySQL权限简介 关于mysql的权限简单的理解就是mysql允许你做你全力以内的事情,不可以越界.比如只允许你执行select操作,那么你就不能执行update操作.只允许你从某台机器上连接m ...

随机推荐

  1. TCP粘包和拆包的定义,产生的原因以及解决方案

    TCP粘包:指发送方发送的若干数据包在接收方接收时粘成一团,从接收缓冲区看,后一包数据的头紧接着前一包数据的尾 产生的原因: 1.发送方的原因:TCP默认使用Nagle算法,而Nagle算法主要做两件 ...

  2. DP(动态规划)总结

    前言 动态规划是很重要的一个知识点,大大小小的比赛总会有一两道DP题,足以说明动态规划的重要性. 动态规划主要是思想,并没有固定的模板,那么,怎么判断题目是不是动态规划呢? DP题一般都会满足三个条件 ...

  3. 44 容器(三)——ArrayList索引相关方法

    方法都比较简单,这里列出来即可: add(index,ele) //忘制定下标插入元素 add(ele) addAll(Collection <C> c) 泛型必须与调用add的泛型保持一 ...

  4. linux中用户环境变量问题

    修改所有用户的环境变量:/etc/profile文件 只修改root用户的环境变量:~/.bashrc文件 只修改某个非root用户的环境变量:/home/非root用户名/.bashrc文件

  5. 2019牛客国庆集训派对day3

    E. Grid 大意: 给定$n\cdot m$个点的图, 初始无边, $q$个操作, $(1,a,b)$表示第$a$列到第$b$列全连起来, $(2,a,b)$表示把第$a$行到第$b$行全连起来, ...

  6. java并发编程之原子操作

    先来看一段简单的代码,稍微有点并发知识的都可以知道打印出结果必然是一个小于20000的值 package com.example.test.cas; import java.io.IOExceptio ...

  7. 2.4_Database Interface ODBC数据库驱动程序类型(单层与多层)

    两大类:单层驱动程序和多层驱动程序 1.单层数据库驱动程序 早期的xBASE数据库系统的驱动程序就属于单层驱动程序. 单层驱动程序不仅要处理ODBC函数调用,还要解释执行SQL语句,执行数据库管理系统 ...

  8. java之hibernate之双向的多对一关联映射

    这篇讲解 双向的多对一关联映射 1.表结构和多对一时,一致 2.类结构 Book.java public class Book implements Serializable{ private int ...

  9. Winform 使用热键功能实现Ctrl+C和Ctrl+V复制粘贴功能

    当我们使用winform控件的时候,会发现这些控件(比如Label)不支持Ctrl+c 复制和Ctrl+v 快捷键复制粘贴功能,如果我们需要实现这个功能改怎么做呢? 1. 首先我们创建一个winfor ...

  10. 论PM与团队与敏捷开发

    敏捷开发是每个有追求的PM都会去读的书 敏捷开发是很少程序会去读的书 敏捷开发是团体其他人很少会读的书 然而, 据我的 所见, 所闻, 所论 敏捷开发在大家的脑袋里分为很多种版本 既有可以一辩的新鲜思 ...