前言·

首先,我们要清楚这个实验的目的是什么:

In this assignment you will add a system call tracing feature that may help you when debugging later labs. You’ll create a new trace system call that will control tracing. It should take one argument, an integer “mask”, whose bits specify which system calls to trace. For example, to trace the fork system call, a program calls trace(1 << SYS_fork), where SYS_fork is a syscall number from kernel/syscall.h. You have to modify the xv6 kernel to print out a line when each system call is about to return, if the system call’s number is set in the mask. The line should contain the process id, the name of the system call and the return value; you don’t need to print the system call arguments. The trace system call should enable tracing for the process that calls it and any children that it subsequently forks, but should not affect other processes.

译:在Xv6的trace命令中,它应该有一个参数,一个整数“掩码”,其位指定要跟踪的系统调用。例如,要跟踪fork系统调用,程序调用trace(1<<SYS_fork),其中SYS_fork是kernel/syscall.h中的系统调用编号。如果系统调用的编号在掩码中设置,则必须修改xv6内核,以便在每个系统调用即将返回时打印出一行。该行应包含进程id系统调用的名称返回值;您不需要打印系统调用参数。跟踪系统调用应启用对调用它的进程及其随后分叉的任何子进程的跟踪,但不应影响其他进程。

注意,在该实验的初始阶段,xv6已经为我们提供了trace命令的用户态实现,但是其底层的系统调用需要我们自己实现。

阅读全文 »

前言·

通过一个项目来学习一下如何设计一个多服务的系统。同时也能学习Spring Cloud Gateway、Dubbo、API签名等一些知识。

项目架构·

阅读全文 »

想写这篇博客的原因是在刷力扣的 347. 前 K 个高频元素 一题时,需要使用到优先队列priority_queue,其定义如下:

1
2
3
4
5
template<
class T,
class Container = std::vector<T>,
class Compare = std::less<typename Container::value_type>
> class priority_queue;

第三个参数是一个可以自定义的比较类型,其必须满足二元谓词,通常可以使用如下两种方法:

  1. 使用自定义的函数对象
  2. lambda表达式
  3. 使用std::greaterstd::less(这里就不介绍这种方法了)
阅读全文 »
0%