zoukankan      html  css  js  c++  java
  • OSTEP第十三章测试题

    2. Now, run free, perhaps using some of the arguments that might be useful (e.g., -m, to display memory totals in megabytes). 
    How much memory is in your system? 
    How much is free? Do these numbers match your intuition?
    siuwhat@siuwhat-PC:~/Desktop/HW-Lottery$ free -m
                  total        used        free      shared  buff/cache   available
    Mem:           1970        1305         123          44         541         461
    Swap:          4095          70        4025
    3. Next, create a little program that uses a certain amount of memory, called memory-user.c. This program should take one command-line argument: the number of megabytes of memory it will use. When run, it should allocate an array, and constantly stream through the array, touching each entry. The program should do this indefinitely, or, perhaps, for a certain amount of time also specified at the command line.
    8. Finally, let’s run pmap on your your memory-user program, with different amounts of used memory. What do you see here? Does the output from pmap match your expectations?
    #include <iostream>
    #include<unistd.h>
    using namespace std;
    int main(int argc, char *argv[]) {
        size_t mem=atoi(argv[1]);
        const size_t num=mem*1024*1024/sizeof(int);
        int array[num];
        while(true){
        for(int i=0;i<num;++i)
            {array[i]=i;
                cout<<getpid()<<"  "<<i<<endl;}
        }
        return 0;
    }

  • 相关阅读:
    拷贝本地文件到docker容器
    python3 使用pip安装(命令行中)失败或 “not a supported wheel” 解决方案!
    Scrapy框架爬虫
    2019227单词记录
    开班第一碗
    函数进阶
    Oracle数组
    oracle merge into使用
    oracle授权替代database link 速度加快
    ora01031:权限不足
  • 原文地址:https://www.cnblogs.com/otakus/p/13222486.html
Copyright © 2011-2022 走看看