本段 132 题 | 来源:backend + general + design | 知识点:操作系统与网络
1. 写程序统计文本文件的总行数。
- 知识点: 操作系统与网络 / 编程语言基础 (主题: python;标签: python, file, count-lines)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 695b5e5b7fd56f69a88e8b5c | 官方: 是 | 付费: 否
答案:
TL;DR使用 sum(1 for _ in f) 或 enumerate 统计行数。
def count_lines(path):
def count_lines(path):
with open(path) as f:
with open(path) as f:
return sum(1 for _ in f)
return sum(1 for _ in f)
print(count_lines("a.txt"))
print(count_lines("a.txt"))
2. 什么是分布式任务调度器(Distributed Job Scheduler)?它解决什么问题,典型使用场景有哪些?
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: distributed-systems, job-scheduler, batch-processing, workflow-orchestration)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 695dfcb61da553795636531d | 官方: 是 | 付费: 否
答案:
TL;DR分布式任务调度器是一种在分布式网络中跨多个节点对任务(Jobs)进行管理、调度、分发与执行的系统,用于自动化并管理大规模任务,例如批处理、报表生成、复杂工作流编排等。
它解决的问题- 将大量任务可靠地分发到多个 worker(Worker)节点执行。
- 在节点故障时能自动重试/重新调度,避免任务丢失。
- 提供任务状态跟踪(queued/running/completed/failed)与监控。
典型使用场景- 批处理(Batch Processing) - 定时报表(Report Generation)
- 跨多节点的复杂工作流编排(Workflow Orchestration)
3. 分布式计数器(Distributed Counter)是什么?它常用于哪些场景?
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: distributed-counter, real-time, eventual-consistency, high-concurrency, counter)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 695dff711da55379563693cc | 官方: 是 | 付费: 否
答案:
TL;DR分布式计数器是一种在大规模分布式系统中用于统计某个指标实时值的计数结构,例如实时在线人数、点赞数、评论数等。它需要在高并发读写下保持可扩展、低延迟、高可用,通常允许最终一致。
典型使用场景- 统计某网页/直播间实时在线人数(如 Reddit、Facebook Live)。
- 统计点赞/反应数(likes/reactions)。
- 统计粉丝数、评论数、投票数。
- 监控系统中的事件计数。
- 风控/反欺诈中的最近用户行为计数。
- 限流系统中统计某用户访问次数。
- 推荐系统中统计用户浏览/购买次数。
- 统计网页访问量以识别 trending 页面。
- 网约车平台统计可用车辆数量。
4. 计算机网络(Computer Network)工作原理(Working Principle)。
- 知识点: 操作系统与网络 (主题: networking;标签: 网络原理)
- 类型: technical | 难度: easy | 子类型:
- 分类: general
- id: 6965b95fa9243c30c8824d25 | 官方: 是 | 付费: 否
答案:
答案将分散的机器(Machine)通过数据通信(Data Communication)原理连接起来,实现共享(Sharing)!
5. 36. 线程(Thread)和进程(Process)的区别?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency;标签: 线程, 进程)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae70 | 官方: 是 | 付费: 否
答案:
答案一个程序(Program)至少有一个进程(Process),一个进程至少有一个线程(Thread),一个进程中也可以有多个线程(Thread)来增加程序的执行速度。
6. 37. 守护线程(Daemon Thread)是什么?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency;标签: daemon thread, GC)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae74 | 官方: 是 | 付费: 否
答案:
答案守护线程(Daemon Thread)是运行在后台的一种特殊进程(Process)。它独立于控制终端(Control Terminal)并且周期性地执行某种任务或等待处理某些发生的事件。在 Java 中垃圾回收线程(Garbage Collection Thread)就是特殊的守护线程(Daemon Thread)。
7. 38. 创建线程(Thread)有哪些几种方式?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency;标签: Thread, Runnable, Callable)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae78 | 官方: 是 | 付费: 否
答案:
答案创建线程(Thread)有三种方式:
- 继承 Thread 重新 run 方法;
- 实现 Runnable 接口;
- 实现 Callable 接口。
8. 39. 说一下 runnable(Runnable)和 callable(Callable)有什么区别?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency;标签: Runnable, Callable)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae7c | 官方: 是 | 付费: 否
答案:
答案runnable(Runnable)没有返回值,callable(Callable)可以拿到有返回值,callable(Callable)可以看作是 runnable(Runnable)的补充。
9. 40. 线程(Thread)有哪些状态?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency;标签: Thread State)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae80 | 官方: 是 | 付费: 否
答案:
答案线程(Thread)的状态:
- NEW 尚未启动
- RUNNABLE 正在执行中
- BLOCKED 阻塞的(被同步锁或者 IO 锁阻塞)
- WAITING 永久等待状态
- TIMED_WAITING 等待指定的时间重新被唤醒的状态
- TERMINATED 执行完成
10. 43. 线程(Thread)的 run()(run Method)和 start()(start Method)有什么区别?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency;标签: run, start)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae8c | 官方: 是 | 付费: 否
答案:
答案start()(start Method)方法用于启动线程(Thread),run()(run Method)方法用于执行线程(Thread)的运行时代码。run()(run Method)可以重复调用,而 start()(start Method)只能调用一次。
11. 46. 线程池(Thread Pool)中 submit()(submit Method)和 execute()(execute Method)方法有什么区别?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency, threadpool;标签: submit, execute)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae98 | 官方: 是 | 付费: 否
答案:
答案- execute()(execute Method):只能执行 Runnable(Runnable)类型的任务。
- submit():可以执行 Runnable 和 Callable 类型的任务。
Callable(Callable)类型的任务可以获取执行的返回值,而 Runnable(Runnable)执行无返回值。
12. 在计算机中,区分主存/内存(primary memory)与辅存(secondary memory)。
- 知识点: 操作系统与网络 / 行为与软技能 (主题: operating-system;标签: Memory)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69703d5d120fcc15912fa690 | 官方: 是 | 付费: 否
答案:
Primary/Main MemoryPrimary memory is the computer memory that is directly accessible by the CPU.
主内存/内存 主内存是可由 CPU 直接访问的计算机内存。
Secondary MemoryBecause the processor does not directly interface with the secondary memory, the contents of the secondary memory must first be transferred to the primary memory before the processor can access it.
辅助存储器由于处理器不直接与辅助存储器接口,因此辅助存储器的内容必须先传输到主存储器,处理器才能访问它。
13. 在 UNIX/Linux 中,sudo(sudo)命令的作用是什么?
- 知识点: 操作系统与网络 / 行为与软技能 (主题: linux, operating-system;标签: sudo)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69703d62120fcc15912faa7b | 官方: 是 | 付费: 否
答案:
sudo is defined as Super Users DO. It runs a command with elevated privileges, typically as the superuser, if the user is permitted in the sudoers file (/etc/sudoers).
sudo 被定义为 Super Users DO。如果用户在 sudoers 文件(/etc/sudoers)中被允许,它会以提升的权限运行命令,通常是以超级用户身份。
14. IBM(IBM)通常会如何通知面试结果?如果想跟进,最佳跟进方式是什么?
- 知识点: 操作系统与网络 / 行为与软技能 (标签: Process, Follow-up)
- 类型: behavioral | 难度: easy | 子类型: behavioral
- 分类: general
- 公司: IBM
- id: 69704120120fcc1591300bfd | 官方: 是 | 付费: 否
答案:
答案常见方式包括邮件/电话/系统状态更新,取决于地区与团队流程。你可以在面试结束时确认时间线(例如 1 周),到期后用邮件礼貌跟进。
跟进邮件要点:简短说明面试日期、表达持续兴趣、询问进度与下一步。
AnswerCommon channels include email, phone, or ATS status updates, depending on region/team process. Confirm the timeline (e.g., one week) and follow up politely after it.
回答常见的渠道包括电子邮件、电话或 ATS 状态更新,具体取决于地区/团队流程。确认时间线(例如一周),并在之后礼貌地跟进。
A follow-up should be brief: interview date, continued interest, and ask for next steps.
跟进应简短:面试日期、持续的兴趣,并询问下一步。
15. 在 C++(C++)中如何分配与释放内存?
- 知识点: 操作系统与网络 / 系统设计/架构 / 编程语言基础 (主题: cpp, memory-management, raii, smart-pointers;标签: new/delete, RAII, unique_ptr, shared_ptr)
- 类型: technical | 难度: easy | 子类型:
- 分类: backend
- 公司: Microsoft
- id: 69787570a39c9c5c3acfb6a8 | 官方: 是 | 付费: 否
答案:
答案基础答案:动态内存用 new(new)分配、delete(delete)释放;数组用 new[](new[])分配、delete[](delete[])释放。更“微软面试加分”的补充是:优先使用 RAII(RAII)与智能指针避免内存泄漏与异常路径泄漏——独占资源用 std::unique_ptr(std::unique_ptr),共享所有权用 std::shared_ptr(std::shared_ptr);容器优先用 std::vector(std::vector)/std::string(std::string)管理动态数组与字符串。只有在必须与底层接口交互时才手写 new/delete,并确保成对、异常安全且无悬空指针。
16. What is the interview process like for a software engineer role at Atlassian?
Atlassian 软件工程师职位的面试流程是怎样的?
- 知识点: 操作系统与网络 / 行为与软技能 (标签: Interview Process, Hiring Bar)
- 类型: behavioral | 难度: easy | 子类型: scenario
- 分类: general
- 公司: Atlassian
- id: 6979de4fc8f1f94b6462c728 | 官方: 是 | 付费: 否
答案:
常见流程:投递简历 → Recruiter(Recruiter)预筛 → Karat(Karat)编程面试 → Virtual Loop(Virtual Loop)(多轮 Coding + System Design + Values)→ Hiring Bar Review(Hiring Bar Review)。Virtual Loop(Virtual Loop)往往持续数小时,既看编码与架构能力,也会评估价值观与协作方式。
17. What should you highlight in the Application Submission stage for Atlassian SWE roles?
在 Atlassian SWE 职位的申请提交阶段,你应该突出什么?
- 知识点: 操作系统与网络 / 行为与软技能 (主题: interviewing;标签: Interview Process)
- 类型: behavioral | 难度: easy | 子类型: scenario
- 分类: general
- 公司: Atlassian
- id: 6979de4fc8f1f94b6462c72b | 官方: 是 | 付费: 否
答案:
强调与岗位技术栈匹配(Java/Kotlin/React/AWS/K8s)并量化影响:CI/CD(CI/CD)、云基础设施、稳定性、数据/AI(AI)工作流等。把你的经历与 Atlassian(Atlassian)的关键方向(云迁移、开发者工具、平台化)明确对应。
18. What happens in the Recruiter Screen for Atlassian?
Atlassian 的招聘人员筛选环节会发生什么?
- 知识点: 操作系统与网络 / 行为与软技能 (主题: interviewing;标签: Interview Process)
- 类型: behavioral | 难度: easy | 子类型: scenario
- 分类: general
- 公司: Atlassian
- id: 6979de4fc8f1f94b6462c72e | 官方: 是 | 付费: 否
答案:
通常 30 分钟左右,会问 “Why Atlassian?”、你喜欢解决什么问题等,并对齐 Team Anywhere(Team Anywhere)的地点/时区偏好与薪资区间。建议多提澄清问题,突出远程协作与跨团队经验。
19. What do you understand about programs and processes in the context of Operating Systems? Differentiate between them.
在操作系统的上下文中,你对程序和进程了解多少?区分它们。
- 知识点: 操作系统与网络 (标签: interviewbit, accolite, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: Accolite Digital
- id: 69b3791b58d557c902b973ce | 官方: 否 | 付费: 否
答案:
- Program: When we run a newly compiled program, the operating system creates a process to run the application. The program's execution begins with GUI mouse clicks, command line entry of the program's name, and so on. Because it remains in secondary memory, such as the contents of a file on disk, a program is a passive entity. Multiple processes can be found in a single program.
- Process: The term process refers to computer program code that has been stored in memory and can be executed by the central processor unit (CPU). A process is an instance of a computer program that is running or an entity that may be allocated to and executed on a processor. When a program is loaded into memory, it becomes a process and hence an active entity.
The following table lists the differences between a program and a process:
下表列出了程序和进程之间的区别:
| Program 程序 | Process 进程 |
|---|---|
| A program consists of a collection of instructions that must be followed in order to execute a certain task. 程序由一组指令组成,必须按顺序执行才能完成某项任务。 | An instance of an executing program is referred to as a process. 正在执行的程序的一个实例称为进程。 |
| Because it is stored in secondary memory, a program is referred to as a passive entity. 因为程序存储在辅助存储器中,所以被称为被动实体。 | Processes are active entities since they are produced and loaded into the main memory during execution. 进程是活动实体,因为它们在执行期间被创建并加载到主存储器中。 |
| A program only exists in one location and will remain thus until it is deleted. 程序只存在于一个位置,并将一直如此直到被删除。 | A process has a finite lifespan because it is terminated after the task is completed. 进程的生命周期有限,因为任务完成后它就会被终止。 |
| A program is also referred to as a static entity. 程序也被称为静态实体。 | A process is also referred to as a dynamic entity. 进程也被称为动态实体。 |
| A program does not require any resources; it only needs memory space to store the instructions. 程序不需要任何资源;它只需要内存空间来存储指令。 | During its lifespan, a process requires a lot of resources, including CPU, memory address, and I/O. 进程在其生命周期内需要大量资源,包括 CPU、内存地址和 I/O。 |
| There is no control block in a program. 程序中没有控制块。 | Process Control Block is a separate control block for each process. 进程控制块是每个进程单独的控制块。 |
| There are two logical components to a program: code and data. 程序有两个逻辑组成部分:代码和数据。 | A process, in addition to program data, requires extra information for administration and execution. 进程除了程序数据外,还需要额外信息用于管理和执行。 |
20. What do you understand about deadlocks in the context of Operating Systems? What are the four necessary conditions for deadlock to happen?
在操作系统的上下文中,你对死锁了解多少?发生死锁的四个必要条件是什么?
- 知识点: 操作系统与网络 (标签: interviewbit, accolite, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Accolite Digital
- id: 69b3791b58d557c902b973e7 | 官方: 否 | 付费: 否
答案:
A deadlock occurs when a group of processes is stalled because each process is holding a resource and waiting for another process to obtain it. Consider the situation when two cars are approaching each other on a narrow bridge and there is only one way: once they are in front of each other, neither of the two cars can move. In operating systems, a similar situation happens when two or more processes hold some resources while waiting on resources owned by other processes (s).
当一组进程因每个进程都持有资源并等待另一个进程获取它而停滞时,就会发生死锁。考虑这样一种情况:两辆车在狭窄的桥上相向而行,只有一条路:一旦它们面对面,两辆车都无法移动。在操作系统中,当两个或多个进程持有某些资源同时等待其他进程拥有的资源时,也会发生类似的情况。
The following are the four necessary conditions for deadlock to take place: - Mutual Exclusion: One or more resources are not available for sharing (Only one process can use at a time)
以下是发生死锁的四个必要条件: - 互斥:一个或多个资源不可共享(一次只能有一个进程使用)
- Hold and Wait: A process is holding at least one resource and waiting for further resources.
- No Preemption: A resource can only be obtained from a process if it is released by the process.
- Circular Wait: A collection of operations is waiting for each other in a circular fashion.
21. What are the key differences between TCP and UDP?
TCP 和 UDP 之间的关键区别是什么?
- 知识点: 操作系统与网络 (标签: interviewbit, apisero, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Apisero
- id: 69b3793b58d557c902b99193 | 官方: 否 | 付费: 否
答案:
The key differences between TCP and UDP are highlighted in the table given below:
TCP 和 UDP 之间的关键区别在下表中突出显示:
| TCP (Transmission Control Protocol) TCP(传输控制协议) | UDP (User Datagram Protocol) UDP(用户数据报协议) |
|---|---|
| TCP (Transmission Control Protocol) is a connection-oriented protocol. The communicating devices should create a connection before transmitting data and close the connection after transmitting the data, according to connection orientation. TCP(传输控制协议)是一种面向连接的协议。根据面向连接的特性,通信设备应在传输数据前建立连接,并在传输数据后关闭连接。 | The User Datagram Protocol (UDP) is a datagram oriented protocol. This is due to the lack of expense associated with creating, maintaining, and terminating connections. For broadcast and multicast network transmission, UDP is a good choice. 用户数据报协议(UDP)是一种面向数据报的协议。这是因为创建、维护和终止连接没有相关开销。对于广播和多播网络传输,UDP 是一个不错的选择。 |
| TCP is dependable because it ensures data delivery to the destination router. TCP 是可靠的,因为它确保数据传递到目标路由器。 | In UDP, data delivery to the destination cannot be assured and hence, it is not dependable. 在 UDP 中,无法保证数据传递到目的地,因此它不可靠。 |
| TCP has a number of error checking methods. It is because it allows for data flow control and acknowledgement. TCP 有多种错误检查方法。这是因为它允许数据流控制和确认。 | UDP only provides a checksum-based error checking mechanism. UDP 仅提供基于校验和的错误检查机制。 |
| There is an acknowledgement segment in TCP. TCP 中有确认段。 | There is no acknowledgement segment in UDP. UDP 中没有确认段。 |
| TCP is slower, more complicated, and inefficient than UDP. TCP 比 UDP 更慢、更复杂、效率更低。 | UDP is faster, simple and more efficient than TCP. UDP 比 TCP 更快、更简单、更高效。 |
| The Transmission Control Protocol has a function that allows data to be sequenced. This means that packets arrive at the receiver in the sequence they were sent. 传输控制协议具有允许数据排序的功能。这意味着数据包按发送顺序到达接收方。 | In UDP, there is no data sequencing. The application layer must control the order if it is required. 在 UDP 中,没有数据排序。如果需要,应用层必须控制顺序。 |
| TCP uses a variable-length (20-60) bytes header. TCP 使用可变长度(20-60)字节的报头。 | UDP has a fixed-length header of 8 bytes. UDP 具有固定长度的 8 字节报头。 |
| TCP allows for the retransmission of dropped packets. TCP 允许重传丢失的数据包。 | UDP does not allow for the retransmission of dropped packets. UDP 不允许重传丢失的数据包。 |
| Broadcasting is not supported by TCP. TCP 不支持广播。 | Broadcasting is supported by UDP. UDP 支持广播。 |
| Handshakes such as SYN, ACK, and SYN-ACK are used in TCP. TCP 中使用 SYN、ACK 和 SYN-ACK 等握手。 | It is a connectionless protocol, which means it does not require a handshake. 它是一种无连接协议,这意味着它不需要握手。 |
| TCP is a heavy-weight protocol. TCP 是一种重量级协议。 | UDP is a lightweight protocol. UDP 是一种轻量级协议。 |
| HTTP, HTTPs, FTP, SMTP, and Telnet all use TCP. HTTP、HTTPs、FTP、SMTP 和 Telnet 都使用 TCP。 | DNS, DHCP, TFTP, SNMP, RIP, and VoIP all use UDP. DNS、DHCP、TFTP、SNMP、RIP 和 VoIP 都使用 UDP。 |
22. What do you understand about Spooling in Operating Systems? Give an application of spooling.
你对操作系统中的“假脱机”(Spooling)有何理解?给出假脱机的一个应用。
- 知识点: 操作系统与网络 (标签: interviewbit, apisero, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Apisero
- id: 69b3793b58d557c902b991b5 | 官方: 否 | 付费: 否
答案:
The practice of temporarily storing data so that it can be used and processed by a device, software, or system is known as spooling. Data is supplied to and stored in memory or other volatile storage until a programme or computer requests it for execution. "Simultaneous Peripheral Operations Online" is an acronym for Spooling. The spool is typically stored in physical memory, buffers, or interrupts for Input and Output devices on the computer. To process the spool in ascending order, the FIFO (first in, first out) approach is employed. Spooling is the collection and storage of data from many Input and Output activities in a buffer. Input and Output devices can access this buffer, which is a piece of memory or hard disc. In a distributed context, an operating system performs the following tasks: - Data spooling for Input and Output devices with varying data access rates is handled.
临时存储数据以便设备、软件或系统使用和处理的做法称为假脱机。数据被提供并存储在内存或其他易失性存储中,直到程序或计算机请求执行它。“同时外围操作在线”是假脱机的首字母缩写。假脱机通常存储在物理内存、缓冲区或计算机输入输出设备的中断中。为了按升序处理假脱机,采用先进先出(FIFO)方法。假脱机是在缓冲区中收集和存储来自许多输入输出活动的数据。输入输出设备可以访问这个缓冲区,它是一块内存或硬盘。在分布式环境中,操作系统执行以下任务:- 处理具有不同数据访问速率的输入输出设备的假脱机数据。
- Maintains the spooling buffer, which acts as a temporary data storage region while the slower device catches up.
- The spooling process maintains parallel computing because a computer can do input and output in parallel order. It is now possible for a computer to simultaneously read data from a tape, write data to disc, and print data to a tape printer.
The most obvious application of spooling is in Printing. Before being added to the printing queue, the printed papers are held in the SPOOL. Several programmes can run and use the CPU during this period without having to wait for the printer to finish printing each page individually. Many additional features, such as setting priorities, receiving notifications when the printing process is complete, and selecting different types of paper to print on based on the user's preferences, can be added to the Spooling printing process.
假脱机最明显的应用是在打印中。在加入打印队列之前,打印文件被保存在假脱机中。在此期间,多个程序可以运行并使用CPU,而无需等待打印机逐页完成打印。还可以向假脱机打印过程添加许多额外功能,例如设置优先级、打印过程完成时接收通知,以及根据用户偏好选择不同类型的纸张进行打印。
23. What do you understand about Memory Management in Operating Systems and why is it important?
你对操作系统中的内存管理有何理解,为什么它很重要?
- 知识点: 操作系统与网络 / 编程语言基础 (标签: interviewbit, apisero, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Apisero
- id: 69b3793b58d557c902b991bb | 官方: 否 | 付费: 否
答案:
The operating system occupies a portion of memory in a multiprogramming computer, while the rest is used by many processes. Memory management is the practice of dividing memory across many operations. Memory management is an operating system approach for coordinating actions between main memory and disc during the execution of a task. The primary goal of memory management is to maximize memory use.
在多程序设计计算机中,操作系统占用一部分内存,其余部分由许多进程使用。内存管理是在多个操作之间划分内存的做法。内存管理是操作系统在执行任务期间协调主内存和磁盘之间活动的方法。内存管理的主要目标是最大化内存使用。
Memory Management is necessary because of the following reasons: - Before and after the process, allocation and deallocation of memory are needed.
内存管理是必要的,原因如下:- 在进程执行前后,需要分配和释放内存。
- To keep track of how much memory is being consumed by processes.
- To keep fragmentation to a minimum.
- To make the best use of the main memory.
- To keep data safe while a process is running.
24. What are schedulers in Operating Systems? State and illustrate the kinds of schedulers available in Operating Systems.
什么是操作系统中的调度器?说明并举例操作系统中可用的调度器类型。
- 知识点: 操作系统与网络 (标签: interviewbit, apisero, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Apisero
- id: 69b3793b58d557c902b991be | 官方: 否 | 付费: 否
答案:
Schedulers are specialized computer programs that control the scheduling of processes in various ways. Their main task is to decide which jobs to enter into the system and which processes to conduct.
调度器是专门的控制进程调度方式的计算机程序。它们的主要任务是根据各种方式决定将哪些作业进入系统以及执行哪些进程。
The three types of schedulers are as follows: - Long Term Scheduler: A job scheduler is another name for a long term scheduler. Which applications are admitted for processing into the system is determined by a long term scheduler. It selects processes from the ready queue and loads them into memory before executing them. The process is loaded into memory for CPU scheduling. The basic purpose of the job scheduler is to deliver a well-balanced mix of jobs, such as Input and Output and CPU bound workloads. It also controls the amount of multiprogramming done. The average rate of process formation must be equal to the average rate of process departure from the system if the degree of multiprogramming remains constant.
三种调度器如下:- 长期调度器:长期调度器也称为作业调度器。它决定哪些应用程序被接纳进入系统进行处理。长期调度器从就绪队列中选择进程,并在执行前将它们加载到内存中。进程被加载到内存中以供CPU调度。作业调度器的基本目的是提供平衡的作业混合,如输入输出和CPU密集型工作负载。它还控制多程序的程度。如果多程序的程度保持恒定,进程形成的平均速率必须等于进程离开系统的平均速率。
- Medium Term Scheduler: This type of scheduler is used to swap programmes in the main memory. It frees up the RAM that the processes have used up. As a result, the degree of multiprogramming is minimized. The medium-term scheduler is in charge of the swapped out processes.
- Short Term Scheduler: A CPU scheduler is another name for a short term scheduler. Its main purpose is to increase system performance in accordance with the stated set of criteria. It is the shift from the ready to the running stage of a process. The CPU scheduler selects a process from among those that are ready to run and gives it CPU time. Short term schedulers, often known as dispatchers, choose the next process to run.
25. What do you understand about Socket Programming? State the advantages and disadvantages of Sockets in Java.
你对套接字编程有何理解?说明Java中套接字的优点和缺点。
- 知识点: 操作系统与网络 (标签: interviewbit, apisero, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: Apisero
- id: 69b3793b58d557c902b991c7 | 官方: 否 | 付费: 否
答案:
Socket programming is a technique for allowing two network nodes to communicate. One socket (node) listens for traffic on a specified port at a specific IP address, while the other socket connects to it. The listener socket is created by the server while the client is connected to it.
套接字编程是一种允许两个网络节点通信的技术。一个套接字(节点)在特定IP地址的指定端口上监听流量,而另一个套接字连接到它。监听套接字由服务器创建,而客户端连接到它。
Some advantages of Java Sockets are as follows: - Sockets are versatile and sufficient. Socket based programming is straightforward to implement for ordinary communications.
Java套接字的一些优点如下:- 套接字通用且足够强大。基于套接字的编程对于普通通信来说实现简单。
Sockets are to blame for low network traffic. Unlike HTML forms and CGI scripts, which construct and send entire web pages for each new request, Java applets can simply send the changed information.
Some disadvantages of Java Sockets are as follows: - Security constraints can be burdensome at times because a Java applet running in a Web browser can only connect to the machine from which it came and nowhere else on the network.Java套接字的一些缺点如下:- 安全约束有时可能很烦人,因为Web浏览器中运行的Java小程序只能连接到其来源机器,而不能连接网络上的任何其他位置。
- Socket based connections, despite all of Java's advantages, are limited to the delivery of raw data packets between programs. Both the client and the server must provide mechanisms for turning the data into something useful.
- Because data formats and protocols are application-specific, socket-based systems are limited in their reusability.
26. What exactly is a Bootstrap Program in terms of operating systems?
在操作系统方面,引导程序到底是什么?
- 知识点: 操作系统与网络 (标签: interviewbit, arcesium, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: Arcesium
- id: 69b3793d58d557c902b993a8 | 官方: 否 | 付费: 否
答案:
A Bootstrap Program is typically a program that initialises the operating system during the startup of a computer system, in other words, the first program that runs when a computer system starts up. Booting is a method or application for loading the operating system. Overall, the bootstrap program is completely responsible for the operating system's performance and functionality. It is totally stored in boot blocks at a specific spot on the disc. It also locates and loads the kernel into the main memory before starting the program. The Bootstrap Program, as shown in the figure below, lies in the Read-Only Memory (ROM) of our computers and is responsible for reading the Operating Systems and loading them into the RAM (Random Access Memory) of our computers. After then, the operating systems can start other computer devices such as graphics cards, keyboards, and mice.
引导程序通常是在计算机系统启动期间初始化操作系统的程序,换句话说,它是计算机系统启动时运行的第一个程序。引导是一种加载操作系统的方法或应用程序。总的来说,引导程序完全负责操作系统的性能和功能。它完全存储在磁盘上特定位置的引导块中。它还在启动程序之前定位并加载内核到主内存中。如下面的图所示,引导程序位于我们计算机的只读存储器(ROM)中,负责读取操作系统并将其加载到我们计算机的随机存取存储器(RAM)中。之后,操作系统可以启动其他计算机设备,如图形卡、键盘和鼠标。
27. Give a list of the different types of operating systems you are familiar with. Include some examples of each type of operating system as well.
列出你熟悉的操作系统类型不同列表。并包括每种操作系统的一些示例。
- 知识点: 操作系统与网络 (标签: interviewbit, arcesium, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Arcesium
- id: 69b3793d58d557c902b993ab | 官方: 否 | 付费: 否
答案:
The following are some of the several types of operating systems: - Distributed Operating Systems: A distributed operating system (DOS) is software that manages numerous computers as if they were one.
以下是几种操作系统类型中的一些:- 分布式操作系统:分布式操作系统(DOS)是一种将众多计算机当作一台来管理的软件。
- Batch Operating System: This operating system interacts with the computer indirectly. There is a worker who organises linked jobs into batches based on their requirements. It is the operator's responsibility to group jobs that have comparable needs together.
- Real-Time Operating Systems: Real-Time Operating Systems (RTOS) are employed in situations when a significant number of events, the bulk of which are external to the computer system, must be accepted and processed quickly or within a tight deadline. Industrial control, telephone switching equipment, aircraft control, and real-time simulations are examples of such uses.
- Network Operating Systems: Network Operating Systems allow computers with different operating systems to join the same network. It's routinely used in the name of security.
Time-Sharing Operating System: A time-sharing operating system allows numerous people to use the same computer at the same time. This operating system makes the most of the available resources.
Some examples of operating systems are as follows: - Microsoft Windows is an operating system developed by Microsoft (Graphical User Interface Operating System based for Personal Computers)操作系统的一些示例如下:- Microsoft Windows 是由微软开发的操作系统(基于图形用户界面的个人计算机操作系统)
- iOS is Apple's mobile operating system (iPhone, iPad, and iPod Touch operating system)
- MacOS is the operating system that runs on Apple's personal computers and workstations, such as the MacBook and iMac.
- GNU or Linux (for Personal Computers, File and Print server, Workstations, ISP, Three-tier Clients and Servers)
- Android (Google's mobile operating system for smartphones, tablets, smartwatches, and other devices) is a mobile operating system developed by Google.
28. What do you know about demand paging in operating systems?
你对操作系统中的请求分页了解多少?
- 知识点: 操作系统与网络 (标签: interviewbit, arcesium, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Arcesium
- id: 69b3793d58d557c902b993ae | 官方: 否 | 付费: 否
答案:
Demand paging in operating systems is a strategy for loading pages (a page is the smallest unit of data for memory management in a virtual memory operating system). A page frame is the smallest contiguous unit of physical memory with a predetermined length into which the operating system maps memory pages) only when they are needed. Virtual Memory is a storage allocation method that makes it possible to address secondary memory as if it were the main memory. The addresses used by a program to refer to memory are different from the addresses used by the memory system to designate physical storage sites, and the addresses created by the program are automatically converted to machine addresses. The quantity of secondary memory available is defined by the number of main storage sites available rather than the actual number of main storage locations, and the capacity of virtual storage is restricted by the computer system's addressing scheme.
操作系统中的请求分页是一种仅在需要时才加载页面(页面是虚拟内存操作系统中内存管理的最小数据单位)的策略。页框是具有预定长度的最小连续物理内存单元,操作系统将内存页映射到其中。虚拟内存是一种存储分配方法,它使得可以将辅助存储器当作主存储器来寻址。程序用于引用内存的地址与内存系统用于指定物理存储位置的地址不同,并且程序创建的地址会自动转换为机器地址。可用辅助存储器的数量由可用主存储位置的数量而非主存储位置的实际数量决定,而虚拟存储器的容量受计算机系统寻址方案的限制。
When a place on the page is addressed during execution, the page is only brought into memory. The following are the steps for getting a page into the main memory or demand paging: - An attempt is made by the operating system to visit the page.
当执行期间访问页面上的某个位置时,该页面才会被调入内存。以下是使页面进入主内存或请求分页的步骤:- 操作系统尝试访问该页面。
- If the page is valid, the CPU proceeds to process instructions as usual (in memory).
- When a page is wrong, the operating system performs a page fault trap.
- The operating system then examines the memory reference to see if it is a valid reference to a secondary memory location. The process will be cancelled if this is not the case (illegal memory access). Otherwise, the operating system will have to read the page from the main memory.
- The operating system arranges a disc operation to read the desired page into the main memory.
- The operation that was paused as a result of the operating system trap is then restarted or continued.
29. In the context of operating systems, define microkernels.
在操作系统的上下文中,定义微内核。
- 知识点: 操作系统与网络 (标签: interviewbit, arcesium, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Arcesium
- id: 69b3793e58d557c902b993ed | 官方: 否 | 付费: 否
答案:
One of the kernel's classes is the microkernel. Because it is a kernel, it is in charge of all system resources. In a microkernel, however, user and kernel services are implemented in separate address zones. Because user services are placed in user address space and kernel services are located in kernel address space, the kernel and operating system are both smaller. It just offers the minimal essentials in terms of process and memory management. The execution microkernel is slowed by message forwarding, which is used to establish communication between client programs/applications and services executing in user address space. Because user and kernel services are separated, the Operating System is unaffected if one fails. As a result, one of the microkernel's advantages is enhanced. It's simple to extend since new services are added to the user address space rather than the kernel address area, requiring no kernel changes. It's also portable, secure, and dependable. The architecture of a microkernel is shown below:
内核的类别之一是微内核。由于它是内核,因此负责所有系统资源。然而,在微内核中,用户服务和内核服务在单独的地址区域中实现。由于用户服务位于用户地址空间,而内核服务位于内核地址空间,因此内核和操作系统都更小。它仅在进程和内存管理方面提供最基本的功能。执行微内核会因消息转发而变慢,消息转发用于建立客户端程序/应用程序与在用户地址空间中执行的服务之间的通信。由于用户服务和内核服务是分离的,因此如果其中一个发生故障,操作系统不受影响。因此,微内核的优点之一得到了增强。它易于扩展,因为新服务被添加到用户地址空间而非内核地址区域,无需修改内核。它还具有可移植性、安全性和可靠性。微内核的体系结构如下所示:
The following are some of Microkernel's advantages: - This kernel performs better because of its compact and isolated architecture.
以下是微内核的一些优点:- 由于其紧凑且隔离的体系结构,此内核性能更好。
- The system can be expanded more easily since it can be added to the system application without disrupting the kernel.
30. To connect the C program and the operating system, what structure is used?
使用什么结构来连接 C 程序和操作系统?
- 知识点: 操作系统与网络 (标签: interviewbit, capgemini, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: Capgemini
- id: 69b379f058d557c902ba16d1 | 官方: 否 | 付费: 否
答案:
The file structure is used to connect the operating system and an application. The header file “stdio.h” (standard input/output header file) defines the file. It contains information on the currently open file, its current size, and its memory location. It has a character pointer that indicates which character is currently being opened. When you open a file, you're telling the software and the operating system which file you want to open.
文件结构用于连接操作系统和应用程序。头文件“stdio.h”(标准输入/输出头文件)定义了该文件。它包含有关当前打开文件、其当前大小及其内存位置的信息。它有一个字符指针,指示当前正在打开哪个字符。当您打开文件时,您是在告诉软件和操作系统您要打开哪个文件。
31. What is a DNS (Domain Name System) forwarder?
什么是 DNS(域名系统)转发器?
- 知识点: 操作系统与网络 (标签: interviewbit, capgemini, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Capgemini
- id: 69b379f058d557c902ba16fe | 官方: 否 | 付费: 否
答案:
A DNS forwarder is a DNS server that forwards DNS queries for external DNS names to DNS servers outside the network. A forwarder is used with a DNS server when it receives DNS queries that cannot be resolved quickly. Therefore, it forwards these requests to external DNS servers for resolution.
DNS 转发器是一种 DNS 服务器,它将针对外部 DNS 名称的 DNS 查询转发到网络外部的 DNS 服务器。当 DNS 服务器收到无法快速解析的 DNS 查询时,会使用转发器。因此,它将这些请求转发到外部 DNS 服务器进行解析。
A DNS server that is configured as a forwarder behaves differently than a DNS server that is not configured as a forwarder.
配置为转发器的 DNS 服务器的行为与未配置为转发器的 DNS 服务器不同。
The DNS server behaves as follows when configured as a forwarder: - When the query is received by the DNS server, it resolves it using a cache.
当配置为转发器时,DNS 服务器的行为如下:- 当 DNS 服务器收到查询时,它使用缓存来解析它。
- If the DNS server is not able to resolve the request, it forwards it to another DNS server.
- If the forwarder is not available, it tries to resolve the query using a root hint.
32. How is a TCP connection made?
TCP 连接是如何建立的?
- 知识点: 操作系统与网络 (标签: interviewbit, cisco, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Cisco
- id: 69b37a1258d557c902ba2c98 | 官方: 否 | 付费: 否
答案:
A TCP(Transmission Control Protocol) connection will be done as given below: - Step 1: At first, the receiver (host) will send a packet to the sender (server) with an SYN (SYNchronize) flag. It is considered as an attempt made to open a connection. Then, the server will respond with an SYN flag and ACK (ACKnowledge) flag for acknowledging(approving) the connection. Now, the receiver will send an ACK flag for confirming the handshake. The operating systems at both ends will be kept informed about the connection establishment.
TCP(传输控制协议)连接将如下所示建立:- 步骤 1:首先,接收方(主机)将向发送方(服务器)发送一个带有 SYN(同步)标志的数据包。这被视为尝试打开连接。然后,服务器将回复一个 SYN 标志和 ACK(确认)标志以确认(批准)连接。现在,接收方将发送一个 ACK 标志以确认握手。两端操作系统都将被告知连接建立的情况。
- Step 2: Now the sender will begin data transmission. It will also gain acknowledgements from the receiver. A timer will begin when the sender initiates the sending of data.
- Step 3: The data will be retransmitted by the sender if it hasn’t received any acknowledgements even after the timer limit has been exceeded.
- Step 4: When the receiver buffer is full (in the case of windowing), the receiver will send a stop signal to the sender. The sender will stop the data transmission.
- Step 5: Then after all the data processing is done, the receiver will be sending a go signal into the sender. Now, the sender will again begin transmitting the data.
Successful Tech Career for FREE!
免费开启成功的科技职业生涯!
Successful Tech Career!
成功的技术职业生涯!
Interview Process
面试流程
CTC & Designation
CTC与职位级别
Projects on the Job
工作项目
Referral System
推荐系统
Try It Out
试试看
2 Lakh+ Roadmaps Created
已生成20万+职业规划
33. Explain in detail about Bridges in Networking and mention its usage.
详细解释网络中的网桥并提及其用途。
- 知识点: 操作系统与网络 (标签: interviewbit, cisco, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Cisco
- id: 69b37a1258d557c902ba2ca1 | 官方: 否 | 付费: 否
答案:
A bridge is a networking device that will connect numerous LANs (Local Area Networks) for forming a larger LAN. Also, it can connect LAN segments to form newer LAN segments. It operates in the OSI model’s Data-Link layer. Bridges are helpful in increasing the network capacity of a single LAN by joining multiple LANs.
网桥是一种网络设备,用于连接多个局域网(LAN)以形成一个更大的局域网。它也可以连接局域网网段以形成新的局域网网段。它工作在OSI模型的数据链路层。网桥通过将多个局域网连接起来,有助于提高单个局域网的网络容量。
Working of Bridge:
网桥的工作原理:
The bridge will connect two or more different LANs that are having similar protocols and help to communicate between the devices (nodes) in them. It will accept all the data packets and all of them will be amplified to the other side. The bridges are considered to be intelligent devices as they will permit the passing of only selective packets from them.
网桥将连接两个或多个具有相似协议的不同局域网,并帮助其中的设备(节点)之间进行通信。它将接收所有数据包,并将所有数据包放大到另一侧。网桥被认为是智能设备,因为它们只允许选择性数据包通过。
A bridge will pass only those packets which are addressed from the node of one network to the node of the other network. That means the bridge will consult a database on receiving the data frame for deciding whether to pass, transmit or discard the frame. - If the frame consists of a destination MAC (Media Access Control) address within the same network, then the bridge will pass the frame to that node and discard it later.
网桥只会传递那些从一方网络的节点寻址到另一方网络节点的数据包。这意味着网桥在收到数据帧时会查询数据库,以决定是传递、传输还是丢弃该帧。- 如果帧包含的目的MAC(媒体访问控制)地址位于同一网络内,那么网桥会将该帧传递给该节点并随后丢弃它。
- If the frame consists of a destination MAC address within the connected network, then the bridge will forward the frame towards it.
Uses of Bridge: - The capacity of the network will be increased and multiplied as multiple smaller networks are combined to form a single network using the bridge.
网桥的用途:- 通过使用网桥将多个较小的网络组合成一个单一网络,网络的容量将得到增加和倍增。
- The database in the bridge will help for deciding whether a data frame should be transmitted or discarded on receiving the data frame.
- A single faulty node will be prevented from bringing down the whole network, by deciding on whether to forward or discard the data frame.
- It helps for frame broadcasting to each node even if the MAC or destination address is not available.
- With the help of a wireless bridge, we can connect the wireless networks with wireless segments.
34. Give the reasons why a Layered model is used by the Networking industry.
给出网络行业使用分层模型的原因。
- 知识点: 操作系统与网络 (标签: interviewbit, cisco, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Cisco
- id: 69b37a1258d557c902ba2ca7 | 官方: 否 | 付费: 否
答案:
- It provides systematic troubleshooting in the network.
- It clarifies what task has to be done by general function rather than how to do those tasks.
- Modifications made to one layer doesn't affect the other layers in the layered model.
35. What is the CISCO default TCP session timeout?
CISCO默认的TCP会话超时时间是多少?
- 知识点: 操作系统与网络 (标签: interviewbit, cisco, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Cisco
- id: 69b37a1258d557c902ba2cb0 | 官方: 否 | 付费: 否
答案:
The default timeout in the TCP session for CISCO will be one minute. Here, connection slots will get freed on an average of sixty seconds later, when the sequence of normal connection close has been completed. It can be configured into other settings as per the requirements.
CISCO的TCP会话默认超时时间为一分钟。在这里,当正常连接关闭序列完成后,连接槽位平均会在六十秒后释放。可以根据需求配置为其他设置。
For the connection and translation slots of different protocols, a global idle timeout duration can be set manually. The resources will be returned so that pools can be freed, in case slots are not used for the specified idle time.
对于不同协议的连接和转换槽位,可以手动设置全局空闲超时时间。如果槽位在指定的空闲时间内未被使用,资源将被返还,以便池可以被释放。
36. What is a deadlock in Operating Systems? What are the situations for the deadlock to happen?
操作系统中的死锁是什么?发生死锁的情况有哪些?
- 知识点: 操作系统与网络 (标签: interviewbit, cisco, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Cisco
- id: 69b37a1258d557c902ba2cbc | 官方: 否 | 付费: 否
答案:
Deadlock refers to the situation that happens in the operating system where each process will enter into the waiting state for obtaining the resource which has been assigned to some other process.
死锁是指操作系统中发生的一种情况,其中每个进程都会进入等待状态,以获取已分配给其他进程的资源。
Consider a real-time example of traffic that is going only in a single direction. Here, we can consider the bridge as a resource. If one car backs up, the deadlock situation will be resolved easily. Multiple cars may have to be backed up on deadlock occurrence. So it might lead to starvation.
考虑一个仅单向通行的交通实例。在这里,我们可以将桥梁视为一种资源。如果一辆车倒车,死锁情况将很容易解决。发生死锁时可能需要多辆车倒车。因此,这可能导致饥饿。
The process will be considered to be in a deadlock when the following conditions get satisfied simultaneously: - Mutual Exclusion: When more than one process shares the same resource and all the processes are different, then each process of them has to wait for the other for utilizing the resource as at a time only one process can use the resource.
当以下条件同时满足时,进程将被视为处于死锁状态:- 互斥:当多个进程共享同一资源且所有进程都不同时,它们中的每个进程都必须等待其他进程才能使用该资源,因为一次只有一个进程可以使用该资源。
- Hold and Wait: A process is already holding the resource(at least one) and waiting for resources.
- No pre-emption: We cannot forcefully stop or remove a process among the waiting processes, for releasing the resource.
- Circular Wait: A group of processes will be waiting in a circular manner for the resources held by each other.
37. What is Virtual memory?
什么是虚拟内存?
- 知识点: 操作系统与网络 (标签: interviewbit, cisco, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Cisco
- id: 69b37a1258d557c902ba2cbf | 官方: 否 | 付费: 否
答案:
- Virtual Memory is a method of storage allocation where a part of secondary memory will be emulated as it is the main memory of a computer. The virtual memory will solve the insufficient memory problem by converting part of disk memory into virtual addresses, thus will create a large size of RAM for accomodating the increased memory requirement demand and will provide the illusion that we have a lot of memory. Modern microprocessors will have a built-in Memory Management Unit(MMU) which will translate the virtual addresses into physical addresses.
- The size of virtual storage is limited by the computer system’s addressing scheme and the available quantity of secondary memory will not depend on an actual number of the main storage locations.
- In common, Virtual memory will be implemented through demand paging or in a segmentation system. Also, demand segmentation can be used for providing virtual memory.
38. What is plumbing/piping in Linux or Unix?
Linux或Unix中的管道/管线是什么?
- 知识点: 操作系统与网络 (标签: interviewbit, cognizant, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Cognizant
- id: 69b37a3158d557c902ba4017 | 官方: 否 | 付费: 否
答案:
Plumbing/ Piping refers to the technique of using one program's output as an input to another. For instance, Instead of delivering a folder or drive listing to the main screen, it can be piped and delivered to a file, or sent to the printer to print a hard copy.
管道/管线是指将一个程序的输出用作另一个程序的输入的技术。例如,不是将文件夹或驱动器列表输出到主屏幕,而是可以通过管道将其传输到文件,或发送到打印机打印硬拷贝。
A pipe is a type of redirection (the transfer of standard output to another location) used in Linux and other Unix-like operating systems to transport the output of one command/program/process to another for additional processing. The Unix/Linux systems allow a command's stdout to be connected to another command's stdin. The pipe character ‘|' can be used to do this.
管道是一种重定向(将标准输出传输到另一个位置)类型,用于Linux和其他类Unix操作系统中,将一个命令/程序/进程的输出传输到另一个命令/程序/进程以进行进一步处理。Unix/Linux系统允许将一个命令的stdout连接到另一个命令的stdin。可以使用管道字符‘|'来实现这一点。
39. What is the difference between HTTP and HTTPS?
HTTP和HTTPS有什么区别?
- 知识点: 操作系统与网络 (标签: interviewbit, dassault-systemes, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 达索系统
- id: 69b37a5b58d557c902ba5c0b | 官方: 否 | 付费: 否
答案:
HTTP (Hypertext Transfer Protocol) and HTTPS (HTTP Secure) are both communication protocols used to transfer data over the internet. However, there is a key difference between the two:
HTTP(超文本传输协议)和HTTPS(HTTP安全)都是用于在互联网上传输数据的通信协议。然而,两者之间存在一个关键区别:
| Feature 特性 | HTTP | HTTPS |
|---|---|---|
| Definition 定义 | Hypertext Transfer Protocol is the standard for communication between web browsers and servers. 超文本传输协议是Web浏览器和服务器之间通信的标准。 | HTTPS is a secure version of HTTP that encrypts data transferred between web browsers and servers. HTTPS是HTTP的安全版本,可加密Web浏览器和服务器之间传输的数据。 |
| Security 安全性 | Not secure, data transmitted is in plain text. 不安全,传输的数据为明文。 | Secure, data transmitted is encrypted. 安全,传输的数据经过加密。 |
| Certificate 证书 | Does not require a certificate. 不需要证书。 | Requires a certificate from a trusted certificate authority. 需要来自受信任证书颁发机构的证书。 |
| Port 端口 | Uses port 80. 使用端口80。 | Uses port 443. 使用端口443。 |
| URL | Begins with "http://" 以“http://”开头 | Begins with "https://" 以“https://”开头 |
| Authentication 认证 | Does not provide any authentication. 不提供任何认证。 | Provides authentication to ensure that the user is communicating with the correct website. 提供认证以确保用户与正确的网站通信。 |
| Data protection 数据保护 | Data transferred over HTTP can be intercepted and read by unauthorized parties. 通过HTTP传输的数据可被未授权方截获和读取。 | Data transferred over HTTPS is encrypted and cannot be intercepted or read by unauthorized parties. 通过HTTPS传输的数据经过加密,无法被未授权方截获或读取。 |
| Best use 最佳用途 | When security is not a concern or the website contains only static content. 当安全性不是问题或网站仅包含静态内容时。 | When security is a concern or the website contains sensitive information such as personal or financial data. 当安全性是问题或网站包含敏感信息(如个人或财务数据)时。 |
In the above image, we can see that HTTP uses no encryption which makes data insecure. There is no data protection, so the HTTP Packets can be seen by any anonymous person on the the way from server to the client/web browser.
在上图中,我们可以看到HTTP不使用加密,这使得数据不安全。没有数据保护,因此HTTP数据包在从服务器到客户端/Web浏览器的途中可被任何匿名人员看到。
On the other side, we have HPPS, which is secured because it uses SSL (Secured Socket Layer) that encrypts the data and provides security to it. This protects the data transfer between Serber and the client.
另一方面,我们有HPPS,它是安全的,因为它使用SSL(安全套接字层)来加密数据并为其提供安全性。这保护了Serber与客户端之间的数据传输。
40. What is DNS (Domain Name System)? How does it work?
什么是DNS(域名系统)?它如何工作?
- 知识点: 操作系统与网络 (标签: interviewbit, dxc, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: DXC Technology
- id: 69b37ab758d557c902ba94cf | 官方: 否 | 付费: 否
答案:
DNS is an acronym for Domain Name System. In 1983, Paul Mockapetris and Jon Postel created DNS. It is a naming system that encompasses all internet resources, including physical nodes and applications and is used to quickly locate resources on a network. The Domain Name System (DNS) is an internet service that translates domain names to IP addresses. Users who don't have DNS must know the IP address of the website they want to visit.
DNS是Domain Name System(域名系统)的缩写。1983年,Paul Mockapetris和Jon Postel创建了DNS。它是一个命名系统,涵盖所有互联网资源,包括物理节点和应用程序,用于快速定位网络上的资源。域名系统(DNS)是一种互联网服务,可将域名转换为IP地址。没有DNS的用户必须知道他们想要访问的网站的IP地址。
The working of a Domain Name System: If you wish to go to the "InterviewBit" website, type "https://www.interviewbit.com" into the address bar of your web browser. Once the domain name is entered, then the domain name system will translate the domain name into the IP address which can be easily interpreted by the computer. Using the IP address, the computer can locate the web page requested by the user.
域名系统的工作方式:如果您想访问“InterviewBit”网站,请在Web浏览器的地址栏中输入“https://www.interviewbit.com”。输入域名后,域名系统会将域名转换为计算机可以轻松解释的IP地址。使用该IP地址,计算机可以定位用户请求的网页。
41. What are the four layers of the TCP/IP model in Computer Networks?
计算机网络中TCP/IP模型的四层是什么?
- 知识点: 操作系统与网络 (标签: interviewbit, dxc, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: DXC Technology
- id: 69b37ab758d557c902ba94e1 | 官方: 否 | 付费: 否
答案:
The four layers of the TCP/IP model in Computer Networks are as follows:
计算机网络中TCP/IP模型的四层如下:
- Application Layer: The application layer is where you will find all of the higher-level procedures.
- Transport Layer: The Transport Layer performs almost identically to the OSI transport layer. It allows peer entities on the network to converse with one another.
- Internet Layer: The Internet Layer is the most critical layer that keeps the entire system together is the internet layer. It sends IP packets where they are supposed to go.
- Network Access Layer or Link layer: To suit the needs of the connectionless internet layer, this layer determines which connectivity, such as serial lines or traditional Ethernet, must be employed.
Successful Tech Career for FREE!
免费开启成功的科技职业生涯!
Successful Tech Career!
成功的技术职业生涯!
Interview Process
面试流程
CTC & Designation
CTC与职位级别
Projects on the Job
工作项目
Referral System
推荐系统
Try It Out
试试看
2 Lakh+ Roadmaps Created
已生成20万+职业规划
42. List the various types of operating systems that you are familiar with. List some operating system examples as well.
列出你熟悉的各种类型的操作系统。同时列出一些操作系统示例。
- 知识点: 操作系统与网络 (标签: interviewbit, dxc, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: DXC Technology
- id: 69b37ab758d557c902ba94fc | 官方: 否 | 付费: 否
答案:
Given below are some of the different types of operating systems : - Batch Operating System: This operating system has no direct interaction with the computer. There is an operator who groups related jobs that have the same need into batches. It is the operator's job to group jobs with similar requirements.
下面给出一些不同类型的操作系统:- 批处理操作系统:这种操作系统与计算机没有直接交互。有一个操作员将具有相同需求的相關作业分组为批次。操作员的工作是将具有相似要求的作业分组。
- Distributed Operating Systems (DOS): A distributed operating system (DOS) is software that manages multiple computers as if they were one.
- Network Operating Systems: Computers running different operating systems can connect to a single network using Network Operating Systems. It is frequently utilized for security reasons.
- Time-Sharing Operating System: A time-sharing operating system allows multiple individuals to share computer resources. This type of operating system makes the most of its resources.
Real-Time Operating Systems (RTOS): These types of operating systems are used in situations when a large number of events, the majority of which are external to the computer system, must be accepted and processed promptly or within a tight deadline. Examples of such applications include industrial control, telephone switching equipment, flight control, and real-time simulations.
The following are some examples of operating systems : - Microsoft Windows (Graphical User Interface Operating System based for Personal Computers)以下是一些操作系统的示例:- 微软Windows(基于个人计算机的图形用户界面操作系统)
- Apple's iOS (iPhone, iPad, and iPod Touch operating system)
- Apple's personal computers and workstations, such as the MacBook and iMac, run macOS.
- Linux or GNU (for Personal Computers, File and Print server, Workstations, ISP, Three-tier Clients and Servers)
- Android (Google's mobile operating system for smartphones, tablets, smartwatches, and other devices)
43. What are the different types of Real Time Operating Systems (RTOS)?
实时操作系统(RTOS)有哪些不同类型?
- 知识点: 操作系统与网络 (标签: interviewbit, dxc, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: DXC Technology
- id: 69b37ab758d557c902ba94ff | 官方: 否 | 付费: 否
答案:
The term "Real-Time Operating System" refers to an operating system that is susceptible to real-time limitations, such as ensuring a response within a specified time limit or meeting a specific deadline. A flight control system, for example, or real-time monitoring. The following are the different types of real-time systems having timing constraints: - Soft Real-Time Operating System: A soft real-time system is one whose performance is impaired if the results do not meet the set timing requirements. In a soft real-time system, fulfilling deadlines is not required for every activity, but the process must be completed and the outcome delivered. Even soft real-time systems cannot miss the deadline for every activity or process, which must meet or miss the deadline based on priority. Soft Real-Time Operating Systems include things like phone switches.
术语“实时操作系统”指的是易受实时限制影响的操作系统,例如确保在指定时间限制内做出响应或满足特定截止日期。例如,飞行控制系统或实时监控。以下是具有时间约束的不同类型的实时系统:- 软实时操作系统:软实时系统是指如果结果未满足设定的时间要求,其性能会受损的系统。在软实时系统中,并非每个活动都必须满足截止日期,但进程必须完成并交付结果。即使是软实时系统也不能错过每个活动或进程的截止日期,这必须根据优先级满足或错过截止日期。软实时操作系统的例子包括电话交换机。
- Hard Real-Time Operating System: Timelines are treated as a deadline in a hard real-time system, and they should never be overlooked. Because hard real-time systems have no persistent memory, their procedures must be completed correctly the first time. The Hard Real-Time System must produce correct answers to events in the time allotted. A totally deterministic and time-constrained system is known as a hard real-time system. When tardiness rises, the usefulness of a hard real-time system's result drops sharply, and it may even become negative. The term "tardiness" describes how late a real-time system completes a task in comparison to the deadline. Consider a flight controller system as an example.
44. What do you understand about demand paging in Operating Systems?
你如何理解操作系统中的按需分页?
- 知识点: 操作系统与网络 (标签: interviewbit, dxc, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: DXC Technology
- id: 69b37ab758d557c902ba9505 | 官方: 否 | 付费: 否
答案:
Demand paging in Operating Systems is a technique for loading pages (In a virtual memory operating system, a page is the smallest unit of data for memory management. A page frame is the smallest fixed-length contiguous unit of physical memory into which the operating system maps memory pages) into memory only when they are needed. Virtual Memory is a storage allocation system that allows secondary memory to be addressed as if it were the main memory. The addresses used by a program to refer to memory are distinct from the addresses used by the memory system to designate physical storage sites, and program generated addresses are automatically translated to machine addresses. The capacity of virtual storage is limited by the computer system's addressing method, and the amount of secondary memory available is determined by the number of main storage sites available rather than the actual number of main storage locations.
操作系统中的按需分页是一种仅在需要时将页面(在虚拟内存操作系统中,页面是内存管理的最小数据单位。页框是操作系统映射内存页面到物理内存的最小固定长度连续单元)加载到内存中的技术。虚拟内存是一种存储分配系统,允许将辅助内存视为主内存来寻址。程序用来引用内存的地址与内存系统用来指定物理存储位置的地址不同,程序生成的地址会自动转换为机器地址。虚拟存储的容量受计算机系统寻址方法的限制,可用辅助内存的数量由可用的主存储位置数量决定,而不是实际的主存储位置数量。
A page is only brought into memory in this case when a position on the page is addressed during execution. In general, the steps for bringing a page into the main memory or demand paging are as follows: - The operating system makes an attempt to access the page.
在这种情况下,只有在执行期间寻址到页面上的某个位置时,页面才会被带入内存。一般来说,将页面带入主内存或按需分页的步骤如下:- 操作系统尝试访问该页面。
- The CPU continues processing instructions as usual if the page is valid (in memory).
- A page fault trap is done by the operating systems when a page is incorrect.
- The operating system then checks to see if the memory reference is a legitimate reference to a secondary memory location. If this is not the case, the process will be terminated (illegal memory access). The operating system will have to read the page in the main memory otherwise.
- To read the desired page into the main memory, the operating system schedules a disc operation.
- After that, the operation that was halted due to the operating system trap is restarted or continued.
45. What do you understand about a Bootstrap Program in Operating Systems?
你如何理解操作系统中的引导程序?
- 知识点: 操作系统与网络 (标签: interviewbit, dxc, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: DXC Technology
- id: 69b37ab758d557c902ba9508 | 官方: 否 | 付费: 否
答案:
A Bootstrap Program is usually a program that initializes the operating system during the startup of the computer system, that is, the first program that is run when a computer system boots up. The operating system is loaded using a method or application known as booting. Overall, the performance and functionality of the operating system are solely dependent on the bootstrap programme. It is entirely stored on the disc in boot blocks at a certain location. It also locates and loads the kernel into the main memory, after which the program begins to run.
引导程序通常是计算机系统启动期间初始化操作系统的程序,也就是说,它是计算机系统启动时运行的第一个程序。操作系统通过一种称为引导的方法或应用程序来加载。总体而言,操作系统的性能和功能完全依赖于引导程序。它完全存储在磁盘上的特定位置的引导块中。它还会定位并将内核加载到主内存中,之后程序开始运行。
As we can see in the image given below, the Bootstrap Program resides in the Read-Only Memory (ROM) of our computers and they are the ones to first read the Operating Systems and load it into the RAM (Random Access Memory) of our computers. Only after that, the operating systems can start other devices of the computer like the Graphics cards, keyboards, mouses, etc.
正如我们在下面给出的图像中所看到的,引导程序驻留在我们计算机的只读存储器(ROM)中,它们是首先读取操作系统并将其加载到我们计算机的随机存取存储器(RAM)中的程序。只有在那之后,操作系统才能启动计算机的其他设备,如显卡、键盘、鼠标等。
DXC Interview Preparation
46. List the few types of Operating Systems which you know about. Also list some examples of Operating Systems.
列出你知道的几种操作系统类型。同时列出一些操作系统的示例。
- 知识点: 操作系统与网络 (标签: interviewbit, genpact, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Genpact
- id: 69b37aff58d557c902babf92 | 官方: 否 | 付费: 否
答案:
A few types of Operating Systems which I know about are as follows: - Batch Operating System: A batch operating system is a computer program that automatically sequences jobs without the need for human interaction.
我所了解的一些操作系统类型如下:- 批处理操作系统:批处理操作系统是一种计算机程序,无需人工交互即可自动排列作业顺序。
- Time-Sharing Operating System: Many people can share computer resources with a time-sharing operating system. There is maximum resource utilization in this type of operating system.
- Distributed Operating Systems: A distributed operating system (DOS) is software that manages a number of computers and makes them appear to be one.
- Network Operating System: In-Network Operating Systems, computers with various operating systems can connect to a common network. It is used usually for security purposes.
Real-Time Operating Systems: Real-Time Operating Systems (RTOS) are employed in situations where a great number of events, most of which are external to the computer system, must be accepted and processed quickly or under tight deadlines. Industrial control, telephone switching equipment, aircraft control, and real-time simulations are examples of such uses.
Some examples of Operating Systems are as follows: - Windows (Graphical User Interface Operating System based for Personal Computers)操作系统的一些示例如下:- Windows(基于个人计算机的图形用户界面操作系统)
- GNU or Linux (for Personal Computers, File and Print server, Workstations, ISP, Three-tier Clients and Servers)
- iOS (Apple’s OS for iPhone, iPad, and iPod Touch)
- macOS (for Apple’s Personal Computers and Workstations like MacBook, iMac, etc.
- Android (Google’s Operating System for Google's smartphones, tablets, smartwatches, etc.)
47. What are the different types of Real Time Operating Systems?
实时操作系统有哪些不同类型?
- 知识点: 操作系统与网络 (标签: interviewbit, genpact, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Genpact
- id: 69b37aff58d557c902babf96 | 官方: 否 | 付费: 否
答案:
The term "Real-Time Operating System" refers to a system that is subjected to real-time constraints, i.e., the response must be guaranteed within a certain time restriction or the system must satisfy a specific deadline.
“实时操作系统”一词指的是受实时约束的系统,即必须在特定时间限制内保证响应,否则系统必须满足特定的截止期限。
For instance, a flight control system, real-time monitoring, and so on. Real-time systems with timing constraints include the following types: - Hard Real-Time Operating System — A system of this type will never miss a deadline. The implications of missing the deadline might be disastrous. If tardiness increases, the utility of a hard real-time system's result declines abruptly, and it may even become negative. Tardiness refers to how late a real-time system does a task in comparison to its deadline. As an example, consider a flight controller system.
例如,飞行控制系统、实时监控等。具有时间约束的实时系统包括以下类型:- 硬实时操作系统——这类系统绝不会错过截止期限。错过截止期限的后果可能是灾难性的。如果延迟增加,硬实时系统结果的效用会急剧下降,甚至可能变为负值。延迟是指实时系统完成任务相比其截止期限晚多少。例如,考虑一个飞行控制器系统。
- Soft Real-Time Operating System — This type of system can occasionally miss its deadline with a low likelihood. There are no dire implications if you miss the deadline. With the increasing delay, the utility of a soft real-time system's result rapidly reduces. Switches on phones are examples of Soft Real-Time Operating Systems.
48. What is an operating system? Explain its basic functions?
什么是操作系统?解释其基本功能?
- 知识点: 操作系统与网络 (标签: interviewbit, hashedin, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: HashedIn
- id: 69b37b2f58d557c902badba7 | 官方: 否 | 付费: 否
答案:
Operating Systems (OS) manage and handle all hardware and software resources on a computer. In the early 1950s, GMOs, or general-purpose operating systems, were introduced. OS handles, coordinates, and manages overall activities and shares computer resources. An OS acts as an intermediary between users of computers and the hardware they use.
操作系统(OS)管理并处理计算机上的所有硬件和软件资源。在20世纪50年代初,通用操作系统(GMOs,即general-purpose operating systems)被引入。操作系统处理、协调和管理整体活动,并共享计算机资源。操作系统是计算机用户与其所用硬件之间的中介。
Functions of Operating System -
操作系统的功能 -
The OS performs many tasks. The important OS capabilities are listed below. - OS manages the memory of the System and Processor.
操作系统执行许多任务。重要的操作系统能力如下所列。- 操作系统管理系统和处理器内存。
- OS provides an Interface for users where users can interact with System.
- OS also handles File Management and Device Management.
- OS Schedules resources and jobs for the CPU.
- OS also helps in error detection.
- OS also manages the Security of the System.
49. What is the role of Domain Name System (DNS)?
域名系统(DNS)的作用是什么?
- 知识点: 操作系统与网络 (标签: interviewbit, hcl, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: HCL Technologies
- id: 69b37b3658d557c902badf65 | 官方: 否 | 付费: 否
答案:
The main role of the Domain Name System (DNS) is to translate domain names into IP Addresses. These IP addresses are the ones that computers can understand. It also gives a list of mail servers that accept Emails for each domain name. Every domain name in the DNS will nominate a set of name servers to be authoritative for its DNS records. For example, when a Web address (URL) is typed into a browser, a DNS query is made to learn an IP address of a Web server associated with that name.
域名系统(DNS)的主要作用是将域名翻译成IP地址。这些IP地址是计算机能够理解的地址。它还为每个域名提供接受电子邮件的邮件服务器列表。DNS中的每个域名将指定一组名称服务器作为其DNS记录的权威来源。例如,当在浏览器中输入一个网址(URL)时,会发出DNS查询以了解与该名称关联的Web服务器的IP地址。
50. What do you understand about kernel in the context of Operating Systems?
在操作系统背景下,你对内核有何理解?
- 知识点: 操作系统与网络 (标签: interviewbit, lti, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: LTIMindtree
- id: 69b37b8b58d557c902bb1cea | 官方: 否 | 付费: 否
答案:
The kernel is a component of an operating system that manages computer and hardware functions. It primarily oversees memory and CPU functions. It's a crucial part of any operating system. Kernel serves as a link between applications and hardware-based data processing via inter-process communication and system calls.
内核是操作系统的一个组件,管理计算机和硬件功能。它主要监管内存和CPU功能。它是任何操作系统的重要组成部分。内核通过进程间通信和系统调用充当应用程序与基于硬件的数据处理之间的链接。
When an operating system is loaded, the kernel is loaded initially and remains in memory until the operating system is shut down. It's in charge of things like disk management, task management, and memory management. It determines which processes should be assigned to the CPU and which should be kept in the main memory for execution. It serves as a link between user software and hardware. The kernel's primary goal is to manage communication between software, such as user-level applications, and hardware, such as the CPU and disc memory.
当操作系统加载时,内核首先被加载并保持在内存中,直到操作系统关闭。它负责磁盘管理、任务管理和内存管理等事务。它确定哪些进程应分配给CPU,哪些应保留在主内存中执行。它充当用户软件与硬件之间的链接。内核的主要目标是管理软件(如用户级应用程序)与硬件(如CPU和磁盘内存)之间的通信。
The following are the different types of the kernel in Operating Systems: - Monolithic Kernel - A monolithic kernel is one in which all operating system services run in kernel space. There are interdependencies between the components of the system. It has a large number of lines of code that is difficult to understand.
以下是操作系统中内核的不同类型:- 单体内核 - 单体内核是指所有操作系统服务在内核空间中运行。系统组件之间存在相互依赖关系。它有大量难以理解的代码行。
- MicroKernel - This is a sort of kernel that takes a minimalist approach. It has thread scheduling and virtual memory. With fewer services in kernel space, it is more stable.
- Hybrid Kernel - This is a hybrid kernel that combines both monolithic and microkernel functionality. It combines the monolithic kernel's performance and design with the modularity and stability of a microkernel.
- Exo Kernel - Exo Kernel is a form of the kernel that adheres to the end-to-end philosophy. It uses the fewest possible hardware abstractions. It assigns physical resources to different applications.
Nano Kernel - This is a kernel that provides hardware abstraction but does not provide system services. Because the MicroKernel lacks system services, the Microkernel and Nano Kernel have become interchangeable.
Useful Interview Resources - Java Interview Questions (Core & Advanced)有用的面试资源 - Java面试问题(核心与高级)
- Coding Interview Questions for Practice
- Technical Interview Questions for Practice
- Interview Preparation
51. What do you understand about deadlocks in the context of Operating Systems? What are the necessary conditions for deadlock to occur in a system?
在操作系统上下文中,你对死锁有何理解?系统中发生死锁的必要条件是什么?
- 知识点: 操作系统与网络 (标签: interviewbit, lti, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: LTIMindtree
- id: 69b37b8b58d557c902bb1cf1 | 官方: 否 | 付费: 否
答案:
When a process enters a waiting state because another waiting process is holding the requested resource, it is referred to as a deadlock. A typical difficulty in multi-processing is a deadlock, which occurs when numerous processes share a mutually exclusive resource known as a soft lock or software.
当一个进程因为另一个等待中的进程持有其请求的资源而进入等待状态时,这被称为死锁。多处理中的一个典型难题是死锁,它发生在众多进程共享一个称为软锁或软件的互斥资源时。
The following are the necessary conditions for a deadlock to occur in a system: - No preemption - A resource can only be released freely by the process that is holding it once it has completed its task.
以下是系统中发生死锁的必要条件:- 无抢占 - 资源只能由持有它的进程在完成任务后自由释放。
- Mutual Exclusion - The resource should not be shareable. If the resource is being used by a process, it cannot be used by another process until the current process releases it.
- Hold and wait - Suppose that a process holds onto some of the resources required for its execution. However, some of the resources that it requires are being held by other resources. Deadlock can happen only when this process does not give away its acquired resources and keeps on waiting for the other resources.
- Circular Wait - Two or more processes waiting for each other to complete their task and release the resources should form a cyclic dependency graph. It is only then that no process would be able to complete its execution and a deadlock would be obtained.
52. Explain HTTP and HTTPS protocol in the context of computer networks.
在计算机网络上下文中解释 HTTP 和 HTTPS 协议。
- 知识点: 操作系统与网络 (标签: interviewbit, mindtree, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Mindtree
- id: 69b37bd258d557c902bb4bd7 | 官方: 否 | 付费: 否
答案:
- HTTP: HTTP stands for Hypertext Transfer Protocol. HTTP is a set of rules and standards that regulate how information can be sent across the Internet. HTTP establishes communication standards for web browsers and servers. HTTP is a network protocol that runs on top of TCP at the application layer. HTTP employs hypertext structured text to create a logical link between text-containing nodes. It's also known as the "stateless protocol" since each command is conducted separately, without using the last run command as a reference.
- HTTPS: HTTPS is the acronym for HyperText Transfer Protocol Secure. It is a highly advanced and secure HTTP version. For data communication, it uses port 443. Encrypting all communication using SSL, it provides for secure transactions. It's a hybrid of the SSL/TLS and HTTP protocols. It allows a network server to be identified in an encrypted and safe manner. HTTPS also enables the server and browser to establish a secure encrypted connection. It provides data security in both directions. This assists you in preventing the theft of potentially sensitive information.
53. What is a Critical Section in Operating System?
操作系统中的临界区是什么?
- 知识点: 操作系统与网络 (标签: interviewbit, nagarro, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Nagarro
- id: 69b37bf958d557c902bb616a | 官方: 否 | 付费: 否
答案:
A critical section is a section of code in an operating system where the execution cannot proceed until all threads reach the section. If any thread attempts to access the critical section before the other threads are finished, it will be blocked until all threads have reached the section. As a result, critical sections can be used to ensure that no thread can interrupt another thread's execution.
临界区是操作系统中的一段代码,在其中执行必须等到所有线程都到达该区域才能继续。如果任何线程在其他线程完成之前试图访问临界区,它将被阻塞,直到所有线程都到达该区域。因此,临界区可用于确保没有线程能中断另一个线程的执行。
54. Explain about TCP/IP Protocol?
解释 TCP/IP 协议?
- 知识点: 操作系统与网络 (标签: interviewbit, nagarro, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Nagarro
- id: 69b37bf958d557c902bb6173 | 官方: 否 | 付费: 否
答案:
TCP/IP is the networking protocol that allows computers to communicate with each other over a network. It is the foundation of modern internet communication. TCP/IP is an acronym for Transmission Control Protocol (TCP) and Internet Protocol (IP). Together they form the TCP/IP protocol suite, which is used to route information from one location to another over the internet. These two works together in order to ensure that data is sent from one computer to another without any problems. TCP/IP is the most widely used protocol today because it allows devices on a network to communicate with each other regardless of their location. It's also responsible for routing data between networks, so it's important for any device that needs to send or receive data across networks. This includes computers, smartphones, tablets, and even smart appliances like security cameras and baby monitors.
TCP/IP 是允许计算机通过网络相互通信的网络协议。它是现代互联网通信的基础。TCP/IP 是传输控制协议(TCP)和互联网协议(IP)的缩写。它们共同构成了 TCP/IP 协议套件,用于通过互联网将信息从一个位置路由到另一个位置。这两者协同工作,以确保数据从一台计算机发送到另一台计算机时没有任何问题。TCP/IP 是当今使用最广泛的协议,因为它允许网络上的设备相互通信,无论它们位于何处。它还负责在网络之间路由数据,因此对于任何需要跨网络发送或接收数据的设备都很重要。这包括计算机、智能手机、平板电脑,甚至安全摄像头和婴儿监视器等智能家电。
55. What are Real-Time Operating Systems (RTOS)?
什么是实时操作系统(RTOS)?
- 知识点: 操作系统与网络 (标签: interviewbit, ntt-data, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: NTT DATA
- id: 69b37bff58d557c902bb661b | 官方: 否 | 付费: 否
答案:
RTOS stands for "Real-Time Operating System". An RTOS is a type of operating system that is designed to support real-time applications, which are applications that require a guaranteed response within a specified time period.
RTOS 代表“实时操作系统”。RTOS 是一种操作系统,旨在支持实时应用程序,即需要在指定时间段内保证响应的应用程序。
RTOSs are used in a variety of applications, including industrial control systems, avionics, and automotive systems. They are typically used in situations where the accuracy and timeliness of the system's response is critical, such as in safety-critical systems or systems that control physical processes.
RTOS 用于各种应用,包括工业控制系统、航空电子设备和汽车系统。它们通常用于系统响应的准确性和及时性至关重要的场景,例如安全关键系统或控制物理过程的系统。
An RTOS typically provides the following features: - Preemptive scheduling: The ability to interrupt the execution of a task and run a higher-priority task in its place.
RTOS 通常提供以下功能:- 抢占式调度:能够中断任务的执行并在其位置运行更高优先级的任务。
- Real-time event handling: The ability to process events or interrupts in a timely manner.
- Resource management: The ability to manage and allocate system resources such as memory, I/O devices, and communication channels.
Error handling: The ability to handle and recover from errors or failures that may occur in the system.
An RTOS is a specialized type of operating system that is designed to meet the unique demands of real-time applications. It provides features such as preemptive scheduling, real-time event handling, resource management, and error handling, which are essential for ensuring the accuracy and timeliness of a system’s response. As technology continues to advance and the demand for real-time applications increases, the importance of RTOSs is likely to grow, making them a critical component in a wide range of industries and applications.RTOS 是一种专门类型的操作系统,旨在满足实时应用程序的独特需求。它提供抢占式调度、实时事件处理、资源管理和错误处理等功能,这些对于确保系统响应的准确性和及时性至关重要。随着技术的不断进步和实时应用需求的增加,RTOS 的重要性可能会增长,使其成为广泛行业和应用中的关键组成部分。
56. What port does HTTP use?
HTTP 使用什么端口?
- 知识点: 操作系统与网络 (标签: interviewbit, ntt-data, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: NTT DATA
- id: 69b37bff58d557c902bb662c | 官方: 否 | 付费: 否
答案:
HTTP (Hypertext Transfer Protocol) uses port 80 by default for communication between web servers and clients. However, HTTPS (HTTP Secure), which uses SSL/TLS encryption to secure the communication, typically uses port 443 by default.
HTTP(超文本传输协议)默认使用端口80在Web服务器和客户端之间进行通信。然而,HTTPS(安全超文本传输协议)使用SSL/TLS加密来保护通信,通常默认使用端口443。
57. List some of the most commonly used LINUX commands.
列出一些最常用的LINUX命令。
- 知识点: 操作系统与网络 (标签: interviewbit, nutanix, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Nutanix
- id: 69b37c0258d557c902bb67d2 | 官方: 否 | 付费: 否
答案:
Linux is one of the most commonly used operating systems, with a variety of applications and advances. Knowing the appropriate command to use when working on Linux saves a lot of time and effort. The most common LINUX networking commands are as follows: - Ifconfig (Interface configurator)
Linux是最常用的操作系统之一,具有各种应用和优势。在Linux上工作时知道合适的命令可以节省大量时间和精力。最常见的LINUX网络命令如下:- Ifconfig(接口配置器)
This command displays the route as well as the network interface. It can also be used to set up an interface, assign an IP address to it, and enable or disable it. Syntax: ifconfig - traceroute
此命令显示路由以及网络接口。它还可以用于设置接口、为其分配IP地址以及启用或禁用接口。语法:ifconfig - traceroute
This command is used to troubleshoot a network. It determines the path to the specified goal after detecting the delay. It labels and identifies all of the devices on the path. It takes the path that leads to the destination. It determines the source of network lag and reports it. Syntax : traceroute - tracepath.
此命令用于排查网络问题。它在检测到延迟后确定到指定目标的路径。它标记并识别路径上的所有设备。它采取通向目的地的路径。它确定网络延迟的来源并报告。语法:traceroute - tracepath。
It's a tool for detecting network delays. It follows the path to the selected destination, identifying each step along the way. It recognises the location where your network is weak if it is weak. Syntax: tracepath - Ping (Packet INternet Groper)
这是一个用于检测网络延迟的工具。它跟随到所选目的地的路径,识别沿途的每一步。如果网络薄弱,它会识别出网络薄弱的位置。语法:tracepath - Ping(数据包互联网探测器)
One of the most commonly used network troubleshooting commands on Linux is ping. It determines whether two nodes are connected via the network. To test network connectivity, the ping programme makes an ICMP echo request. It continues to run until it is interrupted. The ctrl+c key can be used to stop the execution.Syntax : ping
ping是Linux上最常用的网络故障排除命令之一。它确定两个节点是否通过网络连接。为了测试网络连接性,ping程序发出ICMP回显请求。它会持续运行直到被中断。可以使用ctrl+c键停止执行。语法:ping
We can also ping directly using the IP address. The "-c" option in the ping command can be used to limit the number of packets sent.Syntax : ping -c - netstat
我们也可以直接使用IP地址进行ping。ping命令中的"-c"选项可用于限制发送的数据包数量。语法:ping -c - netstat
The netstat command in Linux displays network statistics. It displays statistics on many interfaces, such as open sockets, routing tables, and connection information.Syntax: netstat
Linux中的netstat命令显示网络统计信息。它显示许多接口的统计信息,如打开的套接字、路由表和连接信息。语法:netstat
The netstat command is used in a few different ways, as seen below. To view the programs:Syntax: netstat -p
netstat命令有几种不同的使用方式,如下所示。要查看程序:语法:netstat -p
To find out more about the ports: Syntax: netstat -s This provides thorough information on all of the ports.
要了解更多关于端口的信息:语法:netstat -s 这提供了有关所有端口的详细信息。
To receive the routing table's details: Syntax: netstat -r This section contains information about the routing table. - ss
要获取路由表的详细信息:语法:netstat -r 此部分包含有关路由表的信息。 - ss
The ss command in Linux is a substitute for the netstat tool. It's thought to be a lot faster and more informative than netstat. Because ss gets all information from within the kernel userspace, it can respond faster. Syntax: ssAll TCP, UDP, and UNIX socket connections are listed using this command. - hostname:
Linux中的ss命令是netstat工具的替代品。它被认为比netstat更快且信息更丰富。由于ss从内核用户空间获取所有信息,因此它可以更快地响应。语法:ss 此命令列出所有TCP、UDP和UNIX套接字连接。 - hostname:
The simple command Linux hostname is used to view and change a system's hostname. Syntax: hostname - curl
简单的Linux命令hostname用于查看和更改系统的主机名。语法:hostname - curl
curl is a command-line program that allows you to transport data to or from a server using any of the protocols that are supported (HTTP, FTP, IMAP, POP3, SCP, SFTP, SMTP, TFTP, TELNET, LDAP, or FILE). Syntax: curl [options] [URL…] - nslookup
curl 是一个命令行程序,允许您使用所支持的任何协议(HTTP、FTP、IMAP、POP3、SCP、SFTP、SMTP、TFTP、TELNET、LDAP 或 FILE)向服务器传输数据或从服务器传输数据。语法:curl [options] [URL…] - nslookup
The nslookup command in Linux is also used for DNS inquiries. It can be used to receive domain names, IP addresses, and other DNS records. Syntax: nslookup - ip
Linux 中的 nslookup 命令也用于 DNS 查询。它可用于接收域名、IP 地址和其他 DNS 记录。语法:nslookup - ip
This is the most recent version of the ifconfig command. Syntax:ip a ip addr Like ifconfig, this tool displays the details of all networks. This command can also be used to retrieve information about a particular interface. - dig
这是 ifconfig 命令的最新版本。语法:ip a ip addr 与 ifconfig 类似,此工具显示所有网络的详细信息。此命令还可用于检索特定接口的信息。 - dig
Domain Information Groper is the Linux dig command. This command is used to query the DNS name server during a DNS lookup. It's also used to troubleshoot DNS-related problems. Its primary purpose is to verify DNS mappings, MX Records, host addresses, and all other DNS records in order to have a better understanding of the DNS topography. This is a modified version of the nslookup command. Syntax: dig - route
Domain Information Groper 就是 Linux 的 dig 命令。此命令用于在 DNS 查找期间查询 DNS 名称服务器。它也用于排查与 DNS 相关的问题。其主要目的是验证 DNS 映射、MX 记录、主机地址和所有其他 DNS 记录,以便更好地了解 DNS 拓扑。这是 nslookup 命令的修改版本。语法:dig - route
The Linux route command displays and manipulates your system's routing table. A router's job is to figure out the most efficient way to transport packets to their destination. Syntax: route - whois
Linux 的 route 命令显示并操作系统的路由表。路由器的工作是找出将数据包传输到目的地的最有效方式。语法:route - whois
The whois command in Linux is used to get all of the information about a website. You can find out everything you need to know about a website, including its registration and who owns it. Syntax: whois
Linux 中的 whois 命令用于获取网站的所有信息。您可以找到关于网站所需了解的一切信息,包括其注册信息和所有者。语法:whois
58. What do you understand about system calls?
您对系统调用有何理解?
- 知识点: 操作系统与网络 (标签: interviewbit, paytm, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Paytm
- id: 69b37c1358d557c902bb710d | 官方: 否 | 付费: 否
答案:
A system call is a way for a computer programme to request a service from the kernel of the operating system it is executing on. A system call is a program's way of interacting with the operating system. A system call is when a piece of software makes a request to the operating system's kernel. The Application Program Interface (API) is used to provide services from the operating system to user programmes (API). It serves as a link between a process and the operating system, allowing user-level programmes to request services from the operating system. System calls are the sole way to get into the kernel system. Any software that consumes resources must make use of system calls.
系统调用是计算机程序从其运行所在的操作系统内核请求服务的一种方式。系统调用是程序与操作系统交互的一种方式。系统调用是软件向操作系统内核发出请求的行为。应用程序接口(API)用于将操作系统的服务提供给用户程序(API)。它充当进程与操作系统之间的链接,允许用户级程序向操作系统请求服务。系统调用是进入内核系统的唯一途径。任何消耗资源的软件都必须使用系统调用。
59. Describe the Unix kernel in detail.
详细描述 Unix 内核。
- 知识点: 操作系统与网络 (标签: interviewbit, paytm, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Paytm
- id: 69b37c1358d557c902bb7116 | 官方: 否 | 付费: 否
答案:
The UNIX kernel is the heart of the operating system. It connects to the processor, memory, and I/O management, as well as the hardware devices. The kernel manages user requests using system calls that shift the process from user to kernel space. Every time a user process makes a system call, such as read(), fork(), exec(), open(), and so on, a context switch happens. A context switch is a mechanism for changing the state of a process. The process can be stopped until the system call is finished, or it can continue and be notified when the system call is finished through a signal (nonblocking).
UNIX 内核是操作系统的核心。它连接到处理器、内存和 I/O 管理以及硬件设备。内核通过将进程从用户空间切换到内核空间的系统调用来管理用户请求。每当用户进程进行系统调用(例如 read()、fork()、exec()、open() 等)时,都会发生上下文切换。上下文切换是一种改变进程状态的机制。进程可以停止,直到系统调用完成,或者它可以继续运行,并在系统调用通过信号(非阻塞)完成时收到通知。
60. What do you understand about the concept of Virtual memory?
您对虚拟内存的概念有何理解?
- 知识点: 操作系统与网络 (标签: interviewbit, paytm, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Paytm
- id: 69b37c1358d557c902bb7119 | 官方: 否 | 付费: 否
答案:
Virtual memory is a type of memory that is created on the storage device for a brief period of time. When a computer's RAM is drained as a result of numerous processes running at the same time, this happens. The operating system makes a portion of the storage disc available for use as RAM. Virtual memory is significantly slower than main memory because processing power is used by moving data around rather than performing instructions. The operating systems guide explains how memory is managed by the operating system. Latency increases when the computer must use virtual memory. To move data between RAM and virtual memory, the operating system uses swapping. The operating system moves data from processes that aren't in use right now out of RAM and into virtual memory. When the process is required again, the data is copied back into RAM. Using virtual memory slows down the machine since transferring to a hard disc takes much longer than reading and writing RAM.
虚拟内存是一种在存储设备上临时创建的内存。当由于同时运行大量进程而导致计算机的 RAM 被耗尽时,就会发生这种情况。操作系统将部分存储磁盘提供出来用作 RAM。虚拟内存比主内存慢得多,因为处理能力被用于移动数据而非执行指令。操作系统指南解释了操作系统如何管理内存。当计算机必须使用虚拟内存时,延迟会增加。为了在 RAM 和虚拟内存之间移动数据,操作系统使用交换。操作系统将当前未使用的进程的数据从 RAM 移出到虚拟内存中。当再次需要该进程时,数据会被复制回 RAM。使用虚拟内存会减慢机器速度,因为传输到硬盘所需的时间比读写 RAM 长得多。
61. How well do you know Socket Programming? List the benefits and drawbacks of Sockets in Java.
您对 Socket 编程了解多少?列出 Java 中 Socket 的优点和缺点。
- 知识点: 操作系统与网络 (标签: interviewbit, paytm, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: Paytm
- id: 69b37c1358d557c902bb7122 | 官方: 否 | 付费: 否
答案:
Socket programming is a method for allowing two network nodes to communicate with one another. One socket (node) monitors traffic on a specific port at a given IP address, while the other socket connects to it. The server creates the listener socket while the client is connected to it.
Socket 编程是一种让两个网络节点相互通信的方法。一个套接字(节点)在给定 IP 地址的特定端口上监视流量,而另一个套接字连接到它。服务器创建监听套接字,而客户端连接到它。
The following are some of the benefits of Java Sockets: - Sockets are adaptable and plentiful. For routine communications, socket-based programming is simple to build.
以下是 Java Socket 的一些优点: - 套接字灵活且数量充足。对于常规通信,基于套接字的编程易于构建。
Low network traffic is caused by sockets. Unlike HTML forms and CGI scripts, which build and deliver complete web pages for each new request, Java applets can merely send the updated data.
The following are some of the drawbacks of Java Sockets: - Because a Java applet running in a Web browser can only connect to the machine from which it originated and nowhere else on the network, security constraints can be a pain at times.以下是 Java Socket 的一些缺点: - 由于在 Web 浏览器中运行的 Java 小程序只能连接到其来源的机器,而不能连接到网络上的其他任何地方,因此安全限制有时可能会很麻烦。
- Despite all of Java's advantages, socket-based connections are confined to the transfer of raw data packets between programs. Both the client and the server must provide techniques for converting data into usable information.
- Socket-based systems are limited in their reusability since data formats and protocols are application-specific.
62. What are schedulers and how do they work in operating systems? List and demonstrate the various types of schedulers found in operating systems.
什么是调度器,它们在操作系统中如何工作?列出并演示操作系统中发现的各种类型的调度器。
- 知识点: 操作系统与网络 (标签: interviewbit, paytm, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Paytm
- id: 69b37c1358d557c902bb712f | 官方: 否 | 付费: 否
答案:
Schedulers are specialised computer programs that govern how processes are scheduled in various ways. Their primary responsibility is to determine which jobs should be entered into the system and which processes should be carried out.
调度器是专门的计算机程序,以各种方式管理进程的调度。它们的主要职责是确定哪些作业应进入系统以及哪些进程应被执行。
The following are the three types of schedulers : - Long Term Scheduler: A long term scheduler is also known as a task scheduler. A long-term scheduler determines which applications are accepted for processing into the system. Before executing a process, it selects it from the ready queue and loads it into memory. For CPU scheduling, the process is loaded into memory. The job scheduler's primary goal is to deliver a well-balanced mix of operations, including input/output and CPU-bound workloads. It also regulates how much multiprogramming is done. If the degree of multiprogramming remains constant, the average rate of process formation must be equal to the average rate of process departure from the system.
以下是三种类型的调度器:- 长期调度器:长期调度器也称为任务调度器。长期调度器决定哪些应用程序被接受进入系统进行处理。在执行进程之前,它从就绪队列中选择进程并将其加载到内存中。对于CPU调度,进程被加载到内存中。作业调度器的主要目标是提供均衡的操作组合,包括输入/输出和CPU密集型工作负载。它还调节多道程序设计的程度。如果多道程序设计程度保持不变,进程创建的平均速率必须等于进程离开系统的平均速率。
- Medium Term Scheduler: The medium-term scheduler is used to shift programs in the main memory. It frees up RAM that has been consumed by the processes. As a result, multiprogramming is reduced to a minimum. The swapped out processes are managed by the medium-term scheduler.
- Short Term Scheduler: A short term scheduler is also known as a CPU scheduler. Its primary goal is to improve system performance in accordance with a set of predetermined criteria. It is the transition of a process from the ready to the operating state. The CPU scheduler picks one of the ready-to-run processes and allocates CPU time to it. Short term schedulers, often known as dispatchers, choose the next process to run.
63. How do you implement a semaphore in an operating system?
如何在操作系统中实现信号量?
- 知识点: 操作系统与网络 (标签: interviewbit, publicis-sapient, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: Publicis Sapient
- id: 69b37c2058d557c902bb7a32 | 官方: 否 | 付费: 否
答案:
A semaphore is a synchronization object that is used to control access to a shared resource in a multi-threaded program. A semaphore has a count value that is incremented or decremented to indicate the availability of the shared resource. When a thread acquires a semaphore, the count value is decremented, and when the semaphore is released, the count value is incremented.
信号量是一种同步对象,用于控制多线程程序中对共享资源的访问。信号量有一个计数值,通过递增或递减来表示共享资源的可用性。当线程获取信号量时,计数值递减;当信号量被释放时,计数值递增。
To implement a semaphore in an operating system, you can use a variety of techniques, depending on the specific needs of your program. Some common approaches include:
要在操作系统中实现信号量,您可以根据程序的具体需求使用多种技术。一些常见方法包括:
Using a lock variable: One way to implement a semaphore is to use a lock variable that is set to "locked" when the semaphore is acquired, and "unlocked" when the semaphore is released. When a thread attempts to acquire the semaphore, it can check the value of the lock variable and block if it is set to "locked". This approach is simple, but may not be suitable for multi-processor systems.
- 使用锁变量:实现信号量的一种方法是使用锁变量,当信号量被获取时设置为“锁定”,当信号量被释放时设置为“解锁”。当线程尝试获取信号量时,它可以检查锁变量的值,如果设置为“锁定”则阻塞。这种方法简单,但可能不适用于多处理器系统。
Using a lock variable to implement a semaphore is not the correct approach because it does not provide the necessary functionality for allowing multiple threads to access a shared resource. A lock variable only allows one thread to acquire the lock at a time, which would defeat the purpose of using a semaphore to coordinate access to a shared resource.
使用锁变量来实现信号量不是正确的方法,因为它不提供允许多个线程访问共享资源所必需的功能。锁变量只允许一次一个线程获取锁,这将违背使用信号量来协调对共享资源访问的目的。
Instead, a semaphore should use a counter variable that is incremented or decremented to indicate the availability of the shared resource. The counter variable should be initialized to the maximum number of threads that can access the resource simultaneously. When a thread wants to access the shared resource, it attempts to acquire the semaphore by decrementing the counter. If the counter is greater than zero, the thread can access the resource. If the counter is zero, the thread must block until another thread releases the semaphore by incrementing the counter.
相反,信号量应使用计数器变量,通过递增或递减来表示共享资源的可用性。计数器变量应初始化为可同时访问资源的最大线程数。当线程想要访问共享资源时,它尝试通过递减计数器来获取信号量。如果计数器大于零,线程可以访问资源。如果计数器为零,线程必须阻塞,直到另一个线程通过递增计数器释放信号量。
This approach allows multiple threads to access the shared resource simultaneously, up to the maximum number specified by the counter variable. It also ensures that threads are blocked when the shared resource is unavailable and unblocked when it becomes available, allowing for efficient coordination of access to the resource. - Using a kernel semaphore: Some operating systems provide kernel-level semaphores, which are implemented using low-level synchronization mechanisms such as atomic operations or hardware locks. Kernel semaphores can be more efficient than user-level semaphores, but are more difficult to use and may have stricter restrictions on their usage.
这种方法允许多个线程同时访问共享资源,最多达到计数器变量指定的最大数量。它还确保在共享资源不可用时线程被阻塞,在资源可用时被解除阻塞,从而实现对资源访问的高效协调。- 使用内核信号量:一些操作系统提供内核级信号量,它们是使用低级同步机制(如原子操作或硬件锁)实现的。内核信号量可能比用户级信号量更高效,但使用起来更困难,并且对其使用可能有更严格的限制。
Using a mutex and a condition variable: A mutex (short for "mutual exclusion") is a synchronization object that is used to protect shared resources from concurrent access, while a condition variable is a synchronization object that is used to signal the occurrence of a particular condition. Together, a mutex and a condition variable can be used to implement a semaphore by using the mutex to protect the count value and the condition variable to signal changes in the count value.
There are several different ways to implement a semaphore in an operating system, and the best approach depends on the specific needs of your program. Regardless of the technique you choose, it is important to ensure that your semaphore implementation is thread-safe and provides the necessary synchronization to control access to the shared resource.在操作系统中有几种不同的方法来实现信号量,最佳方法取决于程序的具体需求。无论您选择哪种技术,重要的是确保您的信号量实现是线程安全的,并提供必要的同步来控制对共享资源的访问。
64. How do you implement a mutex in an operating system?
如何在操作系统中实现互斥锁?
- 知识点: 操作系统与网络 (标签: interviewbit, publicis-sapient, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: Publicis Sapient
- id: 69b37c2058d557c902bb7a35 | 官方: 否 | 付费: 否
答案:
A mutex (short for "mutual exclusion") is a synchronization object that is used to protect shared resources from concurrent access in a multi-threaded program. When a thread acquires a mutex, it prevents other threads from accessing the shared resource until the mutex is released.
互斥锁(“mutual exclusion”的缩写)是一种同步对象,用于保护多线程程序中的共享资源免受并发访问。当线程获取互斥锁时,它会阻止其他线程访问共享资源,直到互斥锁被释放。
To implement a mutex in an operating system, you can use a variety of techniques, depending on the specific needs of your program. Some common approaches include:
要在操作系统中实现互斥锁,您可以根据程序的具体需求使用多种技术。一些常见方法包括:
Using a lock variable: One way to implement a mutex is to use a lock variable that is set to "locked" when the mutex is acquired, and "unlocked" when the mutex is released. When a thread attempts to acquire the mutex, it can check the value of the lock variable and block if it is set to "locked". This approach is simple, but may not be suitable for multi-processor systems. 2. Using a semaphore: Another way to implement a mutex is to use a semaphore, which is a synchronization object that controls access to a shared resource. A semaphore can be used to implement a mutex by setting the value of the semaphore to 1, and using the "wait" and "signal" operations to acquire and release the mutex. 3. Using a spinlock: A spinlock is a type of mutex that continuously spins in a loop, checking the status of the mutex, until it can acquire the mutex. This approach can be efficient but can consume a lot of CPU time if the mutex is held for a long time. 4. Using a kernel mutex: Some operating systems provide kernel-level mutexes, which are implemented using low-level synchronization mechanisms such as atomic operations or hardware locks. Kernel mutexes can be more efficient than user-level mutexes, but are more difficult to use and may have stricter restrictions on their usage.
- 使用锁变量:实现互斥锁的一种方法是使用锁变量,当互斥锁被获取时设置为“锁定”,当互斥锁被释放时设置为“解锁”。当线程尝试获取互斥锁时,它可以检查锁变量的值,如果设置为“锁定”则阻塞。这种方法简单,但可能不适用于多处理器系统。 2. 使用信号量:实现互斥锁的另一种方法是使用信号量,它是一种控制对共享资源访问的同步对象。可以通过将信号量的值设置为1,并使用“wait”和“signal”操作来获取和释放互斥锁,从而使用信号量实现互斥锁。 3. 使用自旋锁:自旋锁是一种互斥锁,它在循环中不断自旋,检查互斥锁的状态,直到能够获取互斥锁。这种方法可能高效,但如果互斥锁被长时间持有,可能会消耗大量CPU时间。 4. 使用内核互斥锁:一些操作系统提供内核级互斥锁,它们是使用低级同步机制(如原子操作或硬件锁)实现的。内核互斥锁可能比用户级互斥锁更高效,但使用起来更困难,并且对其使用可能有更严格的限制。
There are several different ways to implement a mutex in an operating system, and the best approach depends on the specific needs of your program. Regardless of the technique you choose, it is important to ensure that your mutex implementation is thread-safe and provides the necessary synchronization to protect shared resources.
在操作系统中实现互斥锁有几种不同的方法,最佳方法取决于程序的具体需求。无论您选择哪种技术,重要的是确保您的互斥锁实现是线程安全的,并提供必要的同步来保护共享资源。
65. What are the HTTP and the HTTPS protocol?
HTTP 和 HTTPS 协议是什么?
- 知识点: 操作系统与网络 (标签: interviewbit, qualcomm, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 高通
- id: 69b37c2d58d557c902bb8151 | 官方: 否 | 付费: 否
答案:
The HyperText Transfer Protocol (HTTP) establishes a set of guidelines and requirements for the transmission of information across the World Wide Web (WWW). It facilitates communication between web servers and browsers. Each command in this so-called "stateless protocol" is independent of the one before it. An application layer protocol based on TCP is HTTP. By default, port 80 is used.
超文本传输协议 (HTTP) 为在万维网 (WWW) 上传输信息制定了一套指导原则和要求。它促进了 Web 服务器和浏览器之间的通信。在这个所谓的“无状态协议”中,每条命令都独立于前一条命令。HTTP 是一种基于 TCP 的应用层协议。默认情况下,使用端口 80。
The HyperText Transfer Protocol Secure, sometimes known as Secure HTTP It is a more sophisticated and secure variant of HTTP. SSL/TLS protocol is used to add security on top of HTTP. By encrypting the transmission, it makes transactions more safe and aids in securely identifying network servers. By default, port 443 is used.
超文本传输安全协议,有时也称为安全 HTTP,它是 HTTP 的一种更复杂、更安全的变体。SSL/TLS 协议被用来在 HTTP 之上增加安全性。通过加密传输,它使交易更加安全,并有助于安全地识别网络服务器。默认情况下,使用端口 443。
66. What are system calls?
什么是系统调用?
- 知识点: 操作系统与网络 (标签: interviewbit, siemens, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Siemens
- id: 69b37c5158d557c902bc75cd | 官方: 否 | 付费: 否
答案:
A system call is a method through which a computer programme asks a service from the kernel of the operating system on which it is running. A system call is a method of interacting with the operating system via programmes. When a computer software makes a request to the kernel of the operating system, it is called a system call. The operating system's services are provided to user programmes via the Application Program Interface (API). It acts as a link between a process and the operating system, allowing user-level programmes to request operating system services. The kernel system can only be accessed using system calls. System calls are required for any programmes that use resources.
系统调用是计算机程序向其运行所在的操作系统内核请求服务的一种方法。系统调用是一种通过程序与操作系统交互的方法。当计算机软件向操作系统内核发出请求时,就称为系统调用。操作系统的服务通过应用程序接口 (API) 提供给用户程序。它充当进程和操作系统之间的链接,允许用户级程序请求操作系统服务。内核系统只能通过系统调用来访问。任何使用资源的程序都需要系统调用。
67. Explain the Unix kernel.
解释 Unix 内核。
- 知识点: 操作系统与网络 (标签: interviewbit, siemens, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Siemens
- id: 69b37c5158d557c902bc75db | 官方: 否 | 付费: 否
答案:
The operating system's central core is the UNIX kernel. It connects to the hardware devices, as well as to the processor, memory, and I/O management. Users' requests are managed by the kernel using system calls that move the process from user space to kernel space.
操作系统的核心是 UNIX 内核。它连接到硬件设备,以及处理器、内存和 I/O 管理。用户请求由内核通过系统调用进行管理,这些系统调用将进程从用户空间移动到内核空间。
A context switch occurs every time a user process performs a system call, such as read(), fork(), exec(), open(), and so on. A context switch is a mechanism that allows a process to change its state. The process can either be blocked until the system call is completed, or it can continue and be told of the completion of the system call via a signal (nonblocking).
每当用户进程执行系统调用(例如 read()、fork()、exec()、open() 等)时,都会发生上下文切换。上下文切换是一种允许进程改变其状态的机制。进程可以被阻塞直到系统调用完成,或者它可以继续运行并通过信号(非阻塞)被告知系统调用已完成。
68. What is a virtual memory?
什么是虚拟内存?
- 知识点: 操作系统与网络 (标签: interviewbit, siemens, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Siemens
- id: 69b37c5158d557c902bc75e1 | 官方: 否 | 付费: 否
答案:
A segment of memory that is produced momentarily on the storage device is referred to as virtual memory. It occurs when a computer's RAM gets depleted as a result of multiple processes executing at the same time.
在存储设备上临时产生的一部分内存被称为虚拟内存。当计算机的 RAM 因同时执行多个进程而耗尽时,就会发生这种情况。
A part of the storage disc is made accessible for usage as RAM by the operating system. Because processor power is consumed by moving data around rather than performing instructions, virtual memory is substantially slower than main memory. The operating systems guide shows how the operating system handles memory. When the computer needs to use virtual memory, latency increases. The operating system employs swapping to transport data between RAM and virtual memory. Data from processes that aren't in use right now is moved out of RAM and stored in virtual memory by the operating system. When the process is needed again, it copies the data back into RAM.
操作系统将存储磁盘的一部分设为可用作 RAM。由于处理器能力消耗在来回移动数据而不是执行指令上,虚拟内存比主内存慢得多。操作系统指南展示了操作系统如何处理内存。当计算机需要使用虚拟内存时,延迟会增加。操作系统采用交换技术在 RAM 和虚拟内存之间传输数据。当前未使用的进程的数据被操作系统移出 RAM 并存储在虚拟内存中。当再次需要该进程时,它会将数据复制回 RAM。
As transferring to a hard disc takes far longer than reading and writing RAM, using virtual memory slows down the machine.
由于传输到硬盘所需的时间远长于读写 RAM,因此使用虚拟内存会降低机器的速度。
69. What do you mean by concurrency control?
并发控制是什么意思?
- 知识点: 操作系统与网络 (标签: interviewbit, tcs, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c6a58d557c902bc84da | 官方: 否 | 付费: 否
答案:
Concurrency Control in a Database Management System is a method of controlling multiple operations at the same time without interfering. It ensures that Database transactions are completed in a timely and accurate manner to deliver accurate results without jeopardizing the database's data integrity.
数据库管理系统中的并发控制是一种同时控制多个操作而互不干扰的方法。它确保数据库事务及时且准确地完成,以提供准确的结果,同时不危及数据库的数据完整性。
The concurrency control mechanism is used by DBMS for the following reasons: - Isolation is achieved by reciprocal exclusion of conflicting transactions.
DBMS 使用并发控制机制的原因如下:- 通过相互排斥冲突事务来实现隔离性。
- Conflicts between read-write and write-write must be resolved.
- Constantly preserving execution obstacles in order to maintain database consistency
- The system must keep track of how the concurrent transactions interact. Concurrent-control techniques are used to achieve this control.
70. What is Socket Programming? What Are The Benefits And Drawbacks Of Java Sockets?
什么是套接字编程?Java 套接字的优点和缺点是什么?
- 知识点: 操作系统与网络 / 编程语言基础 (标签: interviewbit, tcs, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c6a58d557c902bc84e0 | 官方: 否 | 付费: 否
答案:
Socket programming is a method of allowing two network nodes to communicate with each other. One socket (node) listens on a specific port at an IP address, while the other socket connects with it. While the client connects to the server, the server creates the listener socket.
套接字编程是一种允许两个网络节点相互通信的方法。一个套接字(节点)在某个IP地址的特定端口上监听,而另一个套接字则与它连接。当客户端连接到服务器时,服务器会创建监听套接字。
Java Socket Benefits: - Sockets are adaptable and adequate. For general communications, efficient socket-based programming is simple to build.
Java套接字的优点:- 套接字适应性强且功能充足。对于一般通信,基于套接字的高效编程易于构建。
Low network traffic is caused by sockets. Unlike HTML forms and CGI scripts, which construct and send entire web pages for each new request, Java applets can simply send the information that has changed.
Java Socket Drawbacks: - Because a Java applet running in a Web browser can only connect to the machine from which it originated and nowhere else on the network, security restrictions can be oppressive at times.Java套接字的缺点:- 因为Web浏览器中运行的Java小程序只能连接到其来源机器,而不能连接到网络上的其他任何地方,所以安全限制有时可能令人感到束缚。
- Despite all of Java's beneficial capabilities, Socket-based connections merely allow for the transmission of raw data packets between programs. Both the client and the server must provide ways for making the data valuable in some way.
- Because data formats and protocols are application-specific, the re-use of socket-based systems is limited.
71. What is the tunnel mode in networking?
网络中的隧道模式是什么?
- 知识点: 操作系统与网络 (标签: interviewbit, tcs, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c6a58d557c902bc84fe | 官方: 否 | 付费: 否
答案:
Tunnel Mode is a way of transmitting data over the Internet that encrypts both the contents and the original IP address information. It secures communications between security gateways, firewalls, and other devices in a Site-to-Site VPN. In Transport Mode or Tunnel Mode, the Encapsulating Security Payload (ESP) is used. ESP encrypts the data and the IP header information in Tunnel Mode.
隧道模式是一种通过互联网传输数据的方式,它同时加密数据内容和原始IP地址信息。它保护了站点到站点VPN中安全网关、防火墙和其他设备之间的通信。在传输模式或隧道模式中,使用了封装安全载荷(ESP)。在隧道模式下,ESP加密数据和IP头信息。
72. What is an operating system?
什么是操作系统?
- 知识点: 操作系统与网络 (标签: interviewbit, tcs-ninja, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c7258d557c902bc8854 | 官方: 否 | 付费: 否
答案:
An OS acts as the bridge between a computer's users and its hardware. The goal of an OS is to offer a setting where a user may conveniently and effectively run a program. The distribution of services and resources, including memory, processors, hardware, and data, maybe a responsibility of an operating system. Programs sort of a traffic controller, a scheduler, a memory management module, I/O programs, and a filing system are among the operating system's programs that are responsible for managing these resources.
操作系统充当计算机用户与其硬件之间的桥梁。操作系统的目标是为用户提供一个可以方便高效地运行程序的环境。分配服务和资源(包括内存、处理器、硬件和数据)可能是操作系统的一项职责。程序如流量控制器、调度器、内存管理模块、输入/输出程序以及文件系统等,都是操作系统中负责管理这些资源的程序。
73. Explain the TCP/IP model?
解释TCP/IP模型?
- 知识点: 操作系统与网络 (标签: interviewbit, tcs-ninja, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c7258d557c902bc8860 | 官方: 否 | 付费: 否
答案:
TCP/IP stands for Transmission Control Protocol/Internet Protocol. It assists us in figuring out the best way to connect a particular computer to the internet and the best way to transfer data between them. When several computer networks are linked together, we can more easily establish a virtual network. To enable communication across large distances, the TCP/IP protocol was created.
TCP/IP代表传输控制协议/互联网协议。它帮助我们发现将特定计算机连接到互联网的最佳方式以及它们之间传输数据的最佳方式。当多个计算机网络连接在一起时,我们可以更容易地建立一个虚拟网络。为了支持远距离通信,创建了TCP/IP协议。
It is a connection-oriented protocol.
它是一种面向连接的协议。
Layers in the TCP/IP model: There are four layers in the TCP model: - Application Layer: It manages the standards for user interfaces and is responsible for node-to-node communication.
TCP/IP模型中的层:TCP模型中有四层:- 应用层:它管理用户界面的标准,并负责节点到节点的通信。
- Transport Layer: It is in charge of ensuring a seamless end-to-end connection and error-free data transfer.
- Internet Layer: It specifies the protocols that control the logical transmission of data throughout the whole network.
- Network Access Layer: The protocols available in this layer enable the physical transport of data while keeping an eye out for hardware addressing.
74. What is TCP/IP Protocol?
什么是TCP/IP协议?
- 知识点: 操作系统与网络 (标签: interviewbit, tcs-nqt, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Tata Consultancy Services
- id: 69b37c7458d557c902bc894d | 官方: 否 | 付费: 否
答案:
TCP stands for Transfer Control Protocol. The TCP is a connection-oriented protocol implemented at the Transport Layer of the OSI Model. TCP is responsible for breaking the data into the form of small frames called framing and later, at the receiver end, it also reassembles the frames back into the sequence to get the data back.
TCP代表传输控制协议。TCP是一种实现于OSI模型传输层的面向连接协议。TCP负责将数据分解成称为帧的小单元,然后在接收端,它再将帧重新组装成序列以恢复数据。
IP stands for Internet Protocol. It is present at the Network Layer of the OSI model. IP is not reliable and it is a connectionless model. IP is responsible for sending and receiving the data that is broken into the form of frames by the TCP. The IP is combined with TCP to form a reliable data sending-receiving Protocol.
IP代表互联网协议。它位于OSI模型的网络层。IP不可靠,是一种无连接模型。IP负责发送和接收由TCP分解成帧的数据。IP与TCP结合形成可靠的发送-接收数据协议。
75. In operating systems, define spooling.
在操作系统中,定义假脱机。
- 知识点: 操作系统与网络 (标签: interviewbit, uber, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: 优步
- id: 69b37c8258d557c902bc908e | 官方: 否 | 付费: 否
答案:
Spooling is the temporary storage of data so that it can be used and processed by a device, software, or system. Data is supplied to and stored in memory or other volatile storage until it is required by a programme or computer for execution. SPOOL is an abbreviation for "Simultaneous Peripheral Operations Online." The spool is typically stored in physical memory, buffers, or interrupts for Input/Output devices on the computer. To process the spool in ascending order, the FIFO (first in, first out) approach is employed. Spooling is the process of gathering data from a large number of Input/Output processes and storing it in a buffer. This buffer is a memory or hard disc area that Input/Output devices can access. In a distributed context, an operating system does the following: - Controls data spooling for Input/Output devices with varying data access rates.
假脱机是数据的临时存储,以便设备、软件或系统可以使用和处理这些数据。数据被提供给并存储在内存或其他易失性存储中,直到程序或计算机需要它执行。SPOOL是“同时进行外围在线操作”的缩写。假脱机数据通常存储在物理内存、缓冲区或用于计算机输入/输出设备的中断中。为了按升序处理假脱机数据,采用FIFO(先进先出)方法。假脱机是从大量输入/输出进程中收集数据并将其存储在缓冲区中的过程。该缓冲区是输入/输出设备可以访问的内存或硬盘区域。在分布式环境中,操作系统执行以下操作:- 控制数据访问速率不同的输入/输出设备的假脱机。
- Maintains the spooling buffer, which acts as a data holding space while the slower device catches up.
- The spooling procedure preserves parallel computing since a computer can perform Input/Output in parallel sequence. The computer can now read data from a tape, write data to disc, and print data to a tape printer all at the same time.
Printing is the most visible application of spooling. Before being added to the printing queue, the papers to be printed are held in the SPOOL. Several programmes can run and use the CPU during this period without having to wait for the printer to finish printing on each paper individually. Many additional features, such as defining priorities, receiving notifications when the printing process is complete, and selecting different types of paper to print on based on the user's preferences, can be added to the Spooling printing process.
打印是假脱机技术最直观的应用。在加入打印队列之前,待打印的文件被保存在SPOOL中。在此期间,多个程序可以运行并使用CPU,而不必等待打印机逐张完成打印。假脱机打印过程中还可以添加许多附加功能,例如定义优先级、在打印过程完成时接收通知,以及根据用户的偏好选择不同类型的纸张进行打印。
Useful Interview Resources
有用的面试资源
- Data Structures Interview Questions & Answers
- Algo Interview Questions
- Software Engineer Resume – Full Guide
- Technical Interview Questions: Complete List
76. Write a code that accepts the URL string and decodes the URL into its tiny version. The output URL must have the predecessor of “https://www.tinyURL/”
编写一段代码,接受URL字符串并将该URL解码为其精简版本。输出的URL必须带有前缀“https://www.tinyURL/”
- 知识点: 操作系统与网络 (标签: interviewbit, virtusa, company-specific)
- 类型: technical | 难度: easy | 子类型: coding
- 分类: general
- 公司: Virtusa
- id: 69b37c8a58d557c902bc9417 | 官方: 否 | 付费: 否
答案:
For example -
例如——
Input URL = “https://www.interviewbit.com/java-interview-questions/”
输入URL = “https://www.interviewbit.com/java-interview-questions/”
The Output will be - “https://www.tinyURL/xsf34”
输出将是 - “https://www.tinyURL/xsf34”
We can do one thing to solve this problem we can create an index that will be used as an index such that it can map to the long URL. And when it wants to access then it can be accessed in constant time.
我们可以做一件事来解决这个问题,我们可以创建一个索引,将其用作索引以便映射到长URL。当需要访问时,可以在常数时间内访问它。
The code implementation can be -
代码实现可以是 -
public class encodeURL{
public class encodeURL{
HashMap<String, String> hm = new HashMap<>();
HashMap<String, String> hm = new HashMap<>();
//Method that generates an encoded URL that will be used as index.
//生成一个将用作索引的编码URL的方法。
private String generateHashURL(){
private String generateHashURL(){
String AlphaNumericString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
String AlphaNumericString = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+"0123456789"
+"abcdefghijklmnopqrstuvxyz";
+"abcdefghijklmnopqrstuvxyz";
StringBuilder sb = new StringBuilder(10);
StringBuilder sb = new StringBuilder(10);
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 10; i++) {
int index = (int)(AlphaNumericString.length() * Math.random());
int index = (int)(AlphaNumericString.length() * Math.random());
sb.append(AlphaNumericString.charAt(index));
sb.append(AlphaNumericString.charAt(index));
}
//This creates a random string and returns it.
//这会创建一个随机字符串并返回它。
return sb.toString();
return sb.toString();
}
// Encodes a URL to a shortened URL and returns it.
// 将一个URL编码为缩短后的URL并返回它。
public String encode(String longUrl) {
public String encode(String longUrl) {
String predecessorURL = "https://www.tinyURL/";
String predecessorURL = "https://www.tinyURL/";
String hashURL = predecessorURL+generateHashURL();
String hashURL = predecessorURL+generateHashURL();
while(hm.containsKey(hashURL)){
while(hm.containsKey(hashURL)){
hashURL = predecessorURL+generateHashURL();
hashURL = predecessorURL+generateHashURL();
}
hm.put(hashURL, longUrl);
hm.put(hashURL, longUrl);
return hashURL;
return hashURL;
}
}
77. What do you know about DNS?
你对DNS了解多少?
- 知识点: 操作系统与网络 (标签: interviewbit, virtusa, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Virtusa
- id: 69b37c8a58d557c902bc9430 | 官方: 否 | 付费: 否
答案:
The Domain Name Service (DNS) is what converts a domain name (such as www.interviewbit.com ) into an IP address 13.227.138.126 . The technical term for this is querying. DNS is what you would use if you wanted to type http://www.interviewbit.com into your web browser. Instead of just typing in the domain, you would type the word interviewbit.com , and the DNS would look up the IP address associated with that domain. Names are great, but IP addresses are harder to remember. To avoid having to memorize the IP addresses of all the devices on your network, you can use a DNS server, which can be configured to return the correct IP address for a particular hostname. This can be done on a single computer or on a server.
域名服务(DNS)是将域名(如 www.interviewbit.com )转换为IP地址 13.227.138.126 的服务。技术术语称之为查询。如果你想要在网页浏览器中输入 http://www.interviewbit.com ,DNS 就是你所需要的。你可以输入 interviewbit.com 这个词,而非仅仅输入域名,DNS 会查找与该域名关联的IP地址。名称很好,但IP地址更难记住。为了避免必须记住网络上所有设备的IP地址,你可以使用DNS服务器,它可以被配置为返回特定主机名的正确IP地址。这可以在单台计算机或服务器上完成。
78. What are the different types of Shells in Linux?
Linux中有哪些不同类型的Shell?
- 知识点: 操作系统与网络 (标签: interviewbit, wipro, company-specific)
- 类型: technical | 难度: easy | 子类型: concept
- 分类: general
- 公司: Wipro
- id: 69b37c9858d557c902bc9ba9 | 官方: 否 | 付费: 否
答案:
SHELL is a program that acts as the interface between the user and the operating system. It is a command-line interface to the Unix operating system. It collects data from you and runs programs depending on that data. The output of the program is displayed once it has completed its execution.
SHELL是一个程序,充当用户与操作系统之间的接口。它是Unix操作系统的命令行界面。它从你那里收集数据,并根据这些数据运行程序。程序执行完成后会显示其输出。
Shell allows us to run commands, programs, and shell scripts. Kernel maintains resources between processes and regulates all-important computer operations. It also restricts hardware access, organizes all performing utilities, and manages resources between processes. Only kernel users have access to the operating system's utilities.
Shell 允许我们运行命令、程序和 shell 脚本。内核维护进程之间的资源并调节所有重要的计算机操作。它还限制硬件访问,组织所有执行实用程序,并管理进程之间的资源。只有内核用户才能访问操作系统的实用程序。
Types of Shells: - The C Shell: It included aliases and command history, among other features. It has features like built-in math and C-like expression syntax that make programming easier.
Shell 的类型: - C Shell:它包含别名和命令历史等功能。它具有内置数学和类似 C 的表达式语法等功能,使编程更容易。
- The Bourne Shell: It's the very first UNIX shell. It is more convenient and faster. It lacks interactive features such as the ability to recall past commands. It also has no built-in support for arithmetic and logical expressions. It is the default shell for the Solaris operating system.
- The Korn Shell: The Bourne shell is a subset of it. As a result, everything in the Bourne shell is supported. It includes interactive elements. Built-in arithmetic and C-like arrays, functions, and string manipulation facilities are among the features. It is more efficient than a C shell. It works with scripts written in the C shell.
The GNU Bourne-Again Shell: It can be used with the Bourne shell. It incorporates Korn and Bourne shell features.
Wipro Interview Preparation
79. 写一段高效代码统计文件中大写字母数量。
- 知识点: 操作系统与网络 / 编程语言基础 (主题: python;标签: python, file, generator)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695b5e597fd56f69a88e88f1 | 官方: 是 | 付费: 否
答案:
TL;DR(TL;DR)用生成器表达式一行统计:逐行遍历,逐字符判断 isupper()(isupper())。
count = sum(1 for line in open("file.txt") for ch in line if ch.isupper())
count = sum(1 for line in open("file.txt") for ch in line if ch.isupper())
print(count)
print(count)
80. Python(Python)中 split()(split())、sub()(sub())、subn()(subn())方法分别做什么?
- 知识点: 操作系统与网络 / 算法与数据结构 / 编程语言基础 (主题: python;标签: python, regex, re)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695b5e5a7fd56f69a88e897f | 官方: 是 | 付费: 否
答案:
TL;DR(TL;DR)它们属于 re(re)模块,用于正则分割与替换。
- split():按正则切割字符串
- sub():替换匹配内容
subn():替换并返回替换次数
import reimport re
print(re.split(r"\s+", "a b c"))
print(re.split(r"\s+", "a b c"))
print(re.sub(r"a", "x", "a1a"))
print(re.sub(r"a", "x", "a1a"))
print(re.subn(r"a", "x", "a1a"))
print(re.subn(r"a", "x", "a1a"))
81. Python(Python)中与文件相关的模块有哪些?它们有什么用?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: python;标签: python, os, shutil)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695b5e5a7fd56f69a88e8998 | 官方: 是 | 付费: 否
答案:
TL;DR用于文件系统(File System)操作,如创建/移动/复制/删除文件与路径(Path)处理。
常见模块- os:系统与路径(Path)、目录(Directory)操作
- os.path:路径处理
- shutil:复制、移动、删除等高层文件操作
82. 解释 Python 中 with 语句(with Statement)的用途与语法(Syntax)。
- 知识点: 操作系统与网络 / 编程语言基础 (主题: python;标签: python, with, context-manager)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695b5e5a7fd56f69a88e899b | 官方: 是 | 付费: 否
答案:
TL;DRwith 用于上下文管理(Context Management)(例如自动关闭文件),避免资源泄露(Resource Leak)。
with open("a.txt", "r") as f:
with open("a.txt", "r") as f:
data = f.read()
data = f.read()
83. Python 支持哪些文件打开模式(File Opening Mode)?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: python;标签: python, file-mode)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695b5e5a7fd56f69a88e89a6 | 官方: 是 | 付费: 否
答案:
TL;DR常见模式:r 读(Read)、w 写(Write)、a 追加(Append)、+ 读写;文本(Text)加 t,二进制(Binary)加 b。
- r, w, a
- rb, wb, ab
- r+, w+, a+
84. 写代码倒序输出文件内容。
- 知识点: 操作系统与网络 / 编程语言基础 (主题: python;标签: python, file, reverse)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695b5e5a7fd56f69a88e89e6 | 官方: 是 | 付费: 否
答案:
TL;DR读取所有行后反转输出,或用 reversed()。
with open("a.txt") as f:
with open("a.txt") as f:
for line in reversed(f.readlines()):
for line in reversed(f.readlines()):
print(line.rstrip())
print(line.rstrip())
85. 如何读取文件中的随机一行?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: python;标签: python, file, random)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695b5e5b7fd56f69a88e8b26 | 官方: 是 | 付费: 否
答案:
TL;DR读取所有行后用 random.choice 随机选一行。
import random
import random
with open("a.txt") as f:
with open("a.txt") as f:
lines = f.readlines()
lines = f.readlines()
print(random.choice(lines).rstrip())
print(random.choice(lines).rstrip())
86. What do file-related modules in Python do? Name some file-related modules in Python.
Python 中与文件相关的模块有什么作用?请列举一些 Python 中与文件相关的模块。
- 知识点: 操作系统与网络 / 编程语言基础 (主题: python;标签: python, os, os.path, shutil)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695b61ca2873cad90bab5f8b | 官方: 是 | 付费: 否
答案:
TL;DRFile-related modules help you work with the filesystem (create/read/copy/move/delete files and directories).
简而言之:文件相关模块帮助你处理文件系统(创建/读取/复制/移动/删除文件和目录)。
Common modules- os: directory operations, environment variables, permissions
常用模块- os:目录操作、环境变量、权限
- os.path: path parsing and manipulation
- shutil: high-level operations like copy/move/remove
87. Describe the OSI Reference Model.
描述 OSI 参考模型。
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: osi, network-layers, networking)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695b63eb2873cad90baba6ca | 官方: 是 | 付费: 否
答案:
TL;DRThe OSI model is a 7-layer framework for network communication: Physical, Data Link, Network, Transport, Session, Presentation, Application.
简而言之:OSI 模型是用于网络通信的 7 层框架:物理层、数据链路层、网络层、传输层、会话层、表示层、应用层。
Layers- Physical: transmits raw bits
各层- 物理层:传输原始比特
- Data Link: link reliability & error handling
- Network: routing & forwarding
- Transport: end-to-end reliability and flow control
- Session: session management
- Presentation: encoding/encryption/format translation
- Application: services like web browsing and email
88. How does a scheduler work in an operating system?
操作系统中的调度器是如何工作的?
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: os, scheduler, cpu, scheduling)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695b63eb2873cad90baba6d0 | 官方: 是 | 付费: 否
答案:
TL;DRAn OS scheduler selects which process/thread runs next by assigning CPU time based on a scheduling policy to maximize responsiveness and efficiency.
简而言之:OS 调度器通过基于调度策略分配 CPU 时间,选择下一个运行的进程/线程,以最大化响应性和效率。
What the scheduler does- Chooses next runnable process/thread
调度器的作用- 选择下一个可运行的进程/线程
- Allocates CPU time slices
Balances throughput vs latency
Common policies- FCFS (First-Come First-Served)常见策略- FCFS(先来先服务)
- Round Robin
- Priority Scheduling
- Multilevel Queue
89. 解释一下长轮询(Long Polling)。
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 行为与软技能 (主题: system-design;标签: long-polling, realtime, http)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695cc0351da553795622a75a | 官方: 是 | 付费: 否
答案:
TL;DR长轮询(Long Polling)通过保持 HTTP 请求(HTTP Request)挂起直到有新数据再返回,达到近实时效果,不依赖 WebSocket(WebSocket)或 SSE(Server-Sent Events)。
长轮询(Long Polling)是一种在不使用 WebSocket(WebSocket)或 Server-Side Events(Server-Side Events)等协议的情况下获取稳定服务器连接的方法。在传统客户端-服务器模型(Client-Server Model)中,该方法较为常见;在 Node.js(Node.js)中,类似技术也被称为下一代开发模型。
其工作方式是:客户端(Client)向服务器(Server)发送请求(Request),服务器(Server)会保持连接直到出现新的信息再响应。一旦服务器(Server)响应,客户端(Client)会再次发起请求(Request)。只有当有数据可用时服务器(Server)才会返回结果。这个过程会持续循环,直到客户端(Client)应用或服务端请求结束。
90. 进程(Process)与线程(Thread)之间的主要区别是什么?
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: process, thread, concurrency)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695ccbc31da5537956248f7b | 官方: 是 | 付费: 否
答案:
TL;DR题目原文仅提供了对比图示。
91. Servlet 中最常见的 Session(会话)管理方式有哪些?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java;标签: servlet, session, cookies, httpsession, url-rewriting)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695ccbc41da5537956248fb9 | 官方: 是 | 付费: 否
答案:
TL;DRServlet 常用的 session(会话)管理方式包括:URL 重写(URL Rewriting)、HttpSession、Cookies(Cookie)。
Servlet 中主要有三种 session(会话)管理方法:
URL Rewriting(URL 重写):在每个 URL 中追加唯一 session ID(会话标识符)。浏览器请求新页面时会把 session ID(会话标识符)发送回服务器,服务器据此将请求与特定会话关联。
HttpSession:Servlet 提供的内置接口,用于在服务端保存 session(会话)数据。
Cookies(Cookie):Servlet 将数据发送到客户端浏览器,浏览器保存后在后续请求中回传给服务器。
92. 任务提交层与 worker(工作节点)层如何做 rate limiting(速率限制)?分别要限制什么,为什么需要最大并发(max concurrency)控制?
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: rate-limiting, job-submission, worker-concurrency, throttling, overload-protection)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695dfcb71da55379563653a4 | 官方: 是 | 付费: 否
答案:
TL;DRrate limiting(速率限制)需要在两层做:提交层防止单一 client(客户端)大量提交导致调度系统过载;worker(工作节点)层限制单 worker(工作节点)同时执行任务数,避免 CPU/内存/DB(数据库)被压垮。通过 max concurrency(最大并发)控制执行并发度,可以避免基础设施崩溃与系统雪崩。
1)Job Submission Level Rate Limiting(任务提交层速率限制)- 目标:防止大量 job submission(任务提交)造成 scheduling service(调度服务)超载、超时或失败。
- 做法:按 client/user 做限流,例如每个 client 每分钟最多 1000 次提交。
2)Worker Node Level Rate Limiting(工作节点层速率限制)- 目标:防止 worker(工作节点)同时执行过多 job(任务)导致资源耗尽(CPU/内存/数据库)。 - 做法:设置 worker 的 maximum concurrency,限制每个 worker 同时运行的 jobs 数。
为什么要 max concurrency(最大并发)- 避免执行层把底层基础设施压垮。 - 保证系统在高峰期依然可控、可预测。
- 配合队列形成自然的 backpressure。
93. 设计分布式计数器系统时,候选人应该向面试官澄清哪些问题?面试官给出的参考答案意味着哪些设计约束?
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: requirements-clarification, eventual-consistency, accuracy, high-concurrency, scale)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695dff711da553795636943b | 官方: 是 | 付费: 否
答案:
TL;DR候选人需要确认使用场景、规模、并发、读写比、一致性与精度、存储限制和运维复杂度。面试官给出的答案表明系统需支持互联网规模(10 亿用户、3 亿并发)、读多写少(10:1)、允许最终一致但要求准确、并强调低存储与低运维复杂度。
候选人应问的问题- 主要 use case(用例)是什么?
- 是否 public facing?
- 总用户量是多少?
- 是否高并发?平均并发在线人数?峰值并发?
- 读写比是多少?
- 是否需要强一致?是否允许近似值?
- 存储是否受限?
- 期望的运维复杂度?
面试官回答带来的关键约束- 规模巨大:1B(10 亿)用户、100M(1 亿)平均并发、300M(3 亿)峰值并发。 - 读写比 10:1:读流量远高于写。
- 最终一致即可:一致性不是最优先。
- 必须准确:不能用近似结构(如 HyperLogLog)满足需求。
- 低存储、低运维:方案不能太复杂或太占内存。
94. 为什么 P2P 网络被称为去中心化架构?这种设计带来了哪些好处和代价?
- 知识点: 操作系统与网络 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, networking;标签: decentralization, fault-tolerance, scalability, operational-complexity)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695e0de81da553795637df3b | 官方: 是 | 付费: 否
答案:
TL;DRP2P(Peer-to-Peer)去中心化(Decentralization)是指:没有单一服务器(Server)负责统一管理,peer(对等节点)之间直接互联与共享资源。它带来高韧性、可扩展(Scalability)、低中心成本,但代价是治理更难、节点波动影响性能、运维与安全更复杂。
好处(Benefits)- 更强的容错性(Fault tolerance):某些节点离线不会导致整体不可用。
- 天然水平扩展:peer 越多,带宽/存储/计算资源越多。
- 成本更低:减少依赖昂贵的中心化服务器与带宽。
- 更快的内容分发:就近从多个 peer 获取资源。
代价(Trade-offs)- 缺乏统一控制:难以执行统一策略、数据一致性(Data consistency)、权限治理。 - 管理复杂:节点发现、拓扑维护、性能调优更难。
- 依赖 peer 可用性:peer 波动会影响整体资源与性能。
- 安全风险:恶意 peer 可能投毒、传播恶意内容、发起攻击。
95. P2P 网络有哪些关键特性?请解释 Decentralization(去中心化)、Self-organizing(自组织)、Resource sharing(资源共享)、Direct communication(直接通信)、Scalability(可扩展性)、Fault tolerance(容错性)的含义。
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: system-design, networking;标签: p2p, self-organizing, resource-sharing, fault-tolerance, scalability)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695e0de81da553795637df3e | 官方: 是 | 付费: 否
答案:
TL;DRP2P 的关键特性在于:peer(对等节点)之间直接通信并共享资源,网络能够自组织且随着节点增多而变强;由于没有中心节点,所以更耐故障。
关键特性解释- Decentralization(去中心化):无中央服务器,peer(对等节点)对等。
- Self-organizing(自组织):节点动态加入/退出,网络自动重组;可通过目录服务、DHT、peer exchange 实现发现与连接。
- Resource sharing(资源共享):peer 贡献带宽/存储/计算/内容供其他节点使用。
- Direct communication(直接通信):节点间无需中间服务器中转,降低延迟、提升效率。
- Scalability(可扩展):peer 增加带来总资源提升,网络可水平扩展。
- Fault tolerance(容错):节点失败不会导致整体不可用;通过冗余与多副本提升可靠性。
96. P2P 网络有哪些典型应用?请分别解释文件分发(File distribution)、即时通讯(Instant messaging)、加密货币(Cryptocurrency)、P2P CDN(Content Delivery Network,内容分发网络)、协同计算(Collaborative computing)的核心机制。
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design, networking;标签: bittorrent, messaging, blockchain, cdn, distributed-computing)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 695e0de81da553795637df47 | 官方: 是 | 付费: 否
答案:
TL;DRP2P 的典型应用场景包括:文件共享(File sharing)(BitTorrent)、通讯(Skype/WhatsApp 部分场景)、加密货币(Cryptocurrency)(Bitcoin)、内容分发(Content distribution)(P2P CDN)、协同计算(Collaborative computing)(SETI@home)。核心机制都是:peer(对等节点)直接互联 + 分布式资源提供。
典型应用与机制- 文件共享(File sharing):文件切片,peer(对等节点)同时下载+上传,热门资源分发越快。
- 即时通讯(IM/VoIP):peer 直连或半直连,减少中心中继;对 NAT 穿透要求高。
- 加密货币(Crypto):节点共同维护账本(区块链),通过共识机制验证交易,去中心化信任。
- P2P CDN(内容分发):访问过内容的用户充当缓存节点,热门内容从多个 peer 拉取以降低中心压力。
- 协同计算(Collaborative computing):任务分片分发给大量 peer 并行计算,最终汇总结果。
97. Q10. Describe the OSI Reference Model.
问题10. 描述 OSI 参考模型。
- 知识点: 操作系统与网络 / 算法与数据结构 (标签: computer science fundamentals)
- 类型: technical | 难度: medium | 子类型:
- 分类: general
- 公司: Google
- id: 696470f1a9243c30c87057d3 | 官方: 是 | 付费: 否
答案:
(补充答案·AI 生成(AI-Generated))
OSI(Open Systems Interconnection,开放系统互连)七层(自下而上):1 物理层(Physical layer)(比特/介质);2 数据链路层(Data link layer)(帧、MAC(Media Access Control,介质访问控制)、成帧与差错检测);3 网络层(Network layer)(IP(Internet Protocol,互联网协议)、路由);4 传输层(Transport layer)(TCP/UDP(Transmission Control Protocol/User Datagram Protocol,传输控制协议/用户数据报协议)、端口、可靠传输);5 会话层(Session layer)(会话管理);6 表示层(Presentation layer)(编码/加密/压缩);7 应用层(Application layer)(HTTP/DNS/SMTP(Hypertext Transfer Protocol/Domain Name System/Simple Mail Transfer Protocol,超文本传输协议/域名系统/简单邮件传输协议)等)。记忆:物数网传会表应。数据发送时自上而下封装,接收时自下而上解封装。
98. 说出Servlet(Java Servlet)的生命周期,并说出Servlet和CGI(Common Gateway Interface,通用网关接口)的区别。
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, servlet, web;标签: Servlet Lifecycle, CGI, Multithreading)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 6966f690fa809e6d389d9e78 | 官方: 是 | 付费: 否
答案:
答案Servlet(Java Servlet)被服务器(Server)实例化后,容器运行其init(初始化)方法,请求到达时运行其service(服务)方法,service方法自动派遣运行与请求对应的doXXX方法(doGet,doPost)等,当服务器决定将实例销毁的时候调用其destroy(销毁)方法。
与cgi(Common Gateway Interface,通用网关接口)的区别在于servlet(Java Servlet)处于服务器(Server)进程中,它通过多线程方式运行其service(服务)方法,一个实例可以服务于多个请求,并且其实例一般不会销毁,而CGI(Common Gateway Interface,通用网关接口)对每个请求都产生新的进程,服务完成后就销毁,所以效率上低于servlet(Java Servlet)。
99. HashMap(哈希映射)和 Hashtable(哈希表)的区别。
- 知识点: 操作系统与网络 / 算法与数据结构 / 编程语言基础 (主题: java, collections;标签: HashMap, Hashtable, Thread Safety, null)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 6966f690fa809e6d389d9e8f | 官方: 是 | 付费: 否
答案:
答案HashMap(哈希映射)是Hashtable(哈希表)的轻量级实现(非线程安全的实现),他们都完成了Map(映射)接口,主要区别在于HashMap(哈希映射)允许空(null)键值(key),由于非线程安全,效率上可能高于Hashtable(哈希表)。
HashMap(哈希映射)允许将null作为一个entry(条目)的key(键)或者value(值),而Hashtable(哈希表)不允许。
HashMap(哈希映射)把Hashtable(哈希表)的contains方法去掉了,改成containsvalue(包含值)和containsKey(包含键)。因为contains方法容易让人引起误解。
Hashtable(哈希表)继承自Dictionary(字典)类,而HashMap(哈希映射)是Java1.2引进的Map(映射) interface(接口)的一个实现。
最大的不同是,Hashtable(哈希表)的方法是Synchronize(同步)的,而HashMap(哈希映射)不是,在多个线程(thread)访问Hashtable(哈希表)时,不需要自己为它的方法实现同步(synchronization),而HashMap(哈希映射) 就必须为之提供外同步(如果是ArrayList(数组列表):List(列表) lst = Collections.synchronizedList(new ArrayList());如果是HashMap(哈希映射):Map(映射) map = Collections.synchronizedMap(new HashMap());)。
Hashtable(哈希表)和HashMap(哈希映射)采用的hash(哈希)/rehash(再哈希)算法都大概一样,所以性能不会有很大的差异。
100. sleep(睡眠)() 和 wait(等待)() 有什么区别?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency;标签: sleep, wait, Lock, notify)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 6966f690fa809e6d389d9e99 | 官方: 是 | 付费: 否
答案:
答案sleep(睡眠)是线程类(Thread(线程))的方法,导致此线程(thread)暂停执行指定时间,给执行机会给其他线程(thread),但是监控状态依然保持,到时后会自动恢复。调用sleep(睡眠)不会释放对象锁(object lock)。
wait(等待)是Object(对象)类的方法,对此对象调用wait(等待)方法导致本线程(thread)放弃对象锁(object lock),进入等待此对象的等待锁定池(waiting lock pool),只有针对此对象发出notify(通知)方法(或notifyAll(全部通知))后本线程(thread)才进入对象锁定池(object lock pool)准备获得对象锁(object lock)进入运行状态。
101. 30. 哪些集合类(collection classes)是线程安全(thread-safe)的?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, collections, concurrency;标签: 线程安全, ConcurrentHashMap)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae58 | 官方: 是 | 付费: 否
答案:
答案Vector(向量)、Hashtable(哈希表)、Stack(栈) 都是线程安全(thread-safe)的,而像 HashMap(哈希映射) 则是非线程安全(non-thread-safe)的,不过在 JDK 1.5 之后随着 Java.util.concurrent(Java并发工具包) 并发包的出现,它们也有了自己对应的线程安全(thread-safe)类,比如 HashMap(哈希映射) 对应的线程安全(thread-safe)类就是 ConcurrentHashMap(并发哈希映射)。
102. 35. 并行(parallelism)和并发(concurrency)有什么区别?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency;标签: 并发, 并行)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae6c | 官方: 是 | 付费: 否
答案:
答案- 并行(parallelism):多个处理器(processor)或多核处理器(multi-core processor)同时处理多个任务。
- 并发:多个任务在同一个 CPU 核上,按细分的时间片轮流(交替)执行,从逻辑上来看那些任务是同时执行。
并发(concurrency) = 两个队列(queue)和一台咖啡机。
并行(parallelism) = 两个队列(queue)和两台咖啡机。
103. 41. sleep(睡眠)() 和 wait(等待)() 有什么区别?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency;标签: sleep, wait)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae84 | 官方: 是 | 付费: 否
答案:
答案- 类的不同:sleep(睡眠)() 来自 Thread(线程),wait(等待)() 来自 Object(对象)。
- 释放锁:sleep() 不释放锁;wait() 释放锁。
- 用法不同:sleep() 时间到会自动恢复;wait() 可以使用 notify()/notifyAll() 直接唤醒。
104. 42. notify() 和 notifyAll() 有什么区别?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency;标签: notify, notifyAll)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae88 | 官方: 是 | 付费: 否
答案:
答案notifyAll() 会唤醒所有的线程(thread),notify() 之后唤醒一个线程(thread)。notifyAll() 调用后,会将全部线程(thread)由等待池移到锁池(lock pool),然后参与锁(lock)的竞争,竞争成功则继续执行,如果不成功则留在锁池(lock pool)等待锁(lock)释放然后再次参与竞争。而 notify() 只会唤醒一个线程(thread),具体唤醒哪一个线程(thread)由虚拟机(virtual machine)控制。
105. 44. 创建线程池(thread pool)有哪几种方式?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency, threadpool;标签: ExecutorService, ThreadPoolExecutor)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae90 | 官方: 是 | 付费: 否
答案:
答案线程池(thread pool)创建有七种方式,最核心的是最后一种:
- newSingleThreadExecutor():它的特点在于工作线程数目被限制为 1,操作一个无界的工作队列,所以它保证了所有任务都是被顺序执行,最多会有一个任务处于活动状态,并且不允许使用者改动线程池实例,因此可以避免其改变线程数目;
- newCachedThreadPool():它是一种用来处理大量短时间工作任务的线程池,具有几个鲜明特点:会缓存线程并重用,当无缓存线程可用时,就会创建新的工作线程;如果线程闲置的时间超过 60 秒,则被终止并移出缓存;长时间闲置时,这种线程池不会消耗什么资源。其内部使用 SynchronousQueue 作为工作队列;
- newFixedThreadPool(int nThreads):重用指定数目(nThreads)的线程,其背后使用的是无界的工作队列,任何时候最多有 nThreads 个工作线程是活动的。这意味着,如果任务数量超过了活动队列数目,将会在工作队列中等待空闲线程出现;如果有工作线程退出,将会有新的工作线程被创建,以补足指定的数目 nThreads;
- newSingleThreadScheduledExecutor():创建单线程池,返回 ScheduledExecutorService,可以进行定时或周期性的工作调度;
- newScheduledThreadPool(int corePoolSize):和 newSingleThreadScheduledExecutor() 类似,创建的是一个 ScheduledExecutorService,可以进行定时或周期性的工作调度,区别在于单一工作线程还是多个工作线程;
- newWorkStealingPool(int parallelism):这是一个经常被人忽略的线程池,Java 8 才加入这个创建方法,其内部会构建 ForkJoinPool,利用 Work-Stealing 算法,并行地处理任务,不保证处理顺序;
- ThreadPoolExecutor():是最原始的线程池创建,上面 1-3 创建方式都是对 ThreadPoolExecutor() 的封装。
106. 45. 线程池(thread pool)都有哪些状态?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency, threadpool;标签: ThreadPool, State)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae94 | 官方: 是 | 付费: 否
答案:
答案- RUNNING:这是最正常的状态,接受新的任务(task),处理等待队列(waiting queue)中的任务(task)。
- SHUTDOWN:不接受新的任务提交,但是继续处理等待队列中的任务。
- STOP:不接受新的任务提交,不再处理等待队列中的任务,中断正在执行任务的线程。
- TIDYING:所有的任务都销毁了,workCount 为 0,线程池的状态在转换为 TIDYING 状态时,会执行钩子方法 terminated()。
- TERMINATED:terminated() 方法结束后,线程池的状态就会变成这个。
107. 47. 在 Java 程序中怎么保证多线程(multithreading)的运行安全?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency, locks;标签: synchronized, Lock, ReentrantLock)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2ae9c | 官方: 是 | 付费: 否
答案:
答案- 方法一:使用安全类,比如 Java.util.concurrent 下的类。
- 方法二:使用自动锁 synchronized。
- 方法三:使用手动锁 Lock。
手动锁(manual lock)Java 示例代码如下:
Lock lock = new ReentrantLock();
Lock lock = new ReentrantLock();
lock.lock();
lock.lock();
try {
try {
System.out.println("获得锁(acquire lock)");
} catch (Exception e) {
} catch (Exception e) {
// TODO: handle exception
// TODO: 处理异常
} finally {
} finally {
System.out.println("释放锁(release lock)");
lock.unlock();
lock.unlock();
}
108. 49. 什么是死锁(deadlock)?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency;标签: deadlock, 锁)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2aea4 | 官方: 是 | 付费: 否
答案:
答案当线程(thread)A 持有独占锁(exclusive lock)a,并尝试去获取独占锁(exclusive lock)b 的同时,线程(thread)B 持有独占锁(exclusive lock)b,并尝试获取独占锁(exclusive lock)a 的情况下,就会发生 AB 两个线程(thread)由于互相持有对方需要的锁(lock),而发生的阻塞现象,我们称为死锁(deadlock)。
109. 50. 怎么防止死锁(deadlock)?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency;标签: deadlock prevention, tryLock, lock ordering)
- 类型: technical | 难度: medium | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2aea8 | 官方: 是 | 付费: 否
答案:
答案- 统一加锁顺序:对多个锁(lock)规定全局一致的获取顺序(例如先锁(lock)A 再锁(lock)B),避免循环等待(circular wait)。
- 减少嵌套锁:尽量避免在持有一个锁时再去获取另一个锁,缩小锁的粒度与持有时间。
- 使用 tryLock/超时机制:使用可超时的锁获取方式(如 Lock.tryLock),获取失败则释放已持有的资源并重试或降级处理。
- 避免在锁内执行阻塞操作:例如网络 IO、长时间计算、等待外部资源等,降低锁占用时间。
- 使用更高层并发工具:优先使用 java.util.concurrent 中的并发容器、线程安全队列、原子类等,减少显式加锁需求。
110. 操作系统(operating system)主要 выполня哪些功能?
- 知识点: 操作系统与网络 / 行为与软技能 (主题: operating-system;标签: OS Basics)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69703d5d120fcc15912fa68d | 官方: 是 | 付费: 否
答案:
An operating system's functions are as follows:
操作系统的功能如下:
- User interface
- Maintains system functionality
- Security
- Error detection
- Memory Management
- Device Management
- File Management
111. 在操作系统中,什么是进程(process)与线程(thread)?
- 知识点: 操作系统与网络 / 行为与软技能 (主题: operating-system;标签: Process, Thread)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69703d5d120fcc15912fa694 | 官方: 是 | 付费: 否
答案:
ProcessA process is any program that is currently being executed.
进程:进程是任何正在执行的程序。
ThreadA thread is a segment of a process, which means that a process can have multiple threads that are all contained within it.
线程:线程是进程的一部分,这意味着一个进程可以有多个线程,并且所有线程都包含在进程内。
112. 在操作系统中,如何定义死锁(deadlock)?死锁产生需要哪些条件?
- 知识点: 操作系统与网络 / 行为与软技能 (主题: operating-system;标签: Deadlock)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69703d5d120fcc15912fa6b7 | 官方: 是 | 付费: 否
答案:
A deadlock is when two or more processes share resources while waiting for resources held by other processes.
死锁是指两个或多个进程共享资源,同时等待其他进程持有的资源。
Mutual exclusionHold and WaitNo PreemptionCircular Wait
互斥条件持有并等待无剥夺循环等待
113. 在操作系统中,什么是虚拟内存(virtual memory)?
- 知识点: 操作系统与网络 / 行为与软技能 (主题: operating-system;标签: Virtual Memory)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69703d62120fcc15912faa7e | 官方: 是 | 付费: 否
答案:
Virtual memory is a storage allocation method that lets you address secondary memory as if it were main memory. Program addresses are translated to physical addresses by the system.
虚拟内存是一种存储分配方法,允许您将辅助内存当作主内存来寻址。程序地址由系统转换为物理地址。
114. 操作系统中的三类调度器(scheduler)是什么?请分别解释。
- 知识点: 操作系统与网络 / 行为与软技能 (主题: operating-system;标签: Schedulers)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69703d62120fcc15912faa82 | 官方: 是 | 付费: 否
答案:
Schedulers decide which jobs/processes run and when:
调度器决定哪些作业/进程运行以及何时运行:
- Long term Scheduler (LTS)
- Medium Term Schedulers (MTS)
- Short Term Scheduler (STS)
115. 在操作系统中,什么是虚拟内存(virtual memory)?它解决了什么问题?
- 知识点: 操作系统与网络 / 行为与软技能 (主题: operating-system;标签: Virtual Memory)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69703eb2120fcc15912fca5f | 官方: 是 | 付费: 否
答案:
Virtual memory is a storage allocation method that lets you address secondary memory as if it were main memory. Program-generated addresses are translated to machine/physical addresses by the system. The effective virtual memory size is constrained by the addressing scheme and available storage.
虚拟内存是一种存储分配方法,允许您将辅助内存当作主内存来寻址。程序生成的地址由系统转换为机器/物理地址。有效的虚拟内存大小受寻址方案和可用存储空间的限制。
116. 操作系统中的三类调度器(scheduler)是什么?请分别解释它们的职责。
- 知识点: 操作系统与网络 / 行为与软技能 (主题: operating-system;标签: Schedulers)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69703eb2120fcc15912fca66 | 官方: 是 | 付费: 否
答案:
Schedulers are programs that control process scheduling. They decide which jobs enter the system and which processes run.
调度器是控制进程调度的程序。它们决定哪些作业进入系统以及哪些进程运行。
Three categories:
三种类别:
Long term Scheduler (LTS)Selects which processes are admitted into the system and loaded into memory; controls degree of multiprogramming and mix of I/O vs CPU bound jobs.
长期调度器(LTS):选择哪些进程被接纳到系统中并加载到内存中;控制多道程序程度以及I/O密集型和CPU密集型作业的混合比例。
Medium Term Scheduler (MTS)Swaps processes in/out of main memory to free RAM and reduce multiprogramming degree; manages swapped-out processes.
中期调度器(MTS):将进程从主内存中换入/换出,以释放RAM并降低多道程序程度;管理被换出的进程。
Short Term Scheduler (STS)CPU scheduler/dispatcher: selects a ready process to run and allocates CPU time; aims to optimize performance based on criteria.
短期调度器(STS):CPU调度器/分发器:选择就绪进程运行并分配CPU时间;旨在根据标准优化性能。
117. 解释一下 volatile 关键字的含义与使用场景(以 Java/C/C++ 任一为例)。
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, c, cpp, concurrency;标签: volatile, Concurrency)
- 类型: technical | 难度: medium | 子类型: concept
- 分类: backend
- 公司: IBM
- id: 69704120120fcc1591300c00 | 官方: 是 | 付费: 否
答案:
答案核心:volatile 告诉编译器/运行时不要把该变量的读写做不安全的优化缓存(保证“可见性”,不等于“原子性”)。
Java:volatile 保证写入对其他线程可见,并禁止特定重排序;但复合操作(i++)仍需锁/原子类。
C/C++:更多用于与硬件寄存器/中断共享的内存映射 I/O,防止编译器优化掉读写。
AnswerCore idea: volatile prevents unsafe caching/optimizations so reads/writes are visible; it does not automatically make operations atomic.
答案核心思想:volatile可防止不安全的缓存/优化,使读写操作可见;但它并不会自动使操作变为原子操作。
Java: ensures visibility and restricts reordering; compound ops (i++) still need locks/atomics.
Java:确保可见性并限制指令重排序;复合操作(如 i++)仍需要锁或原子类。
C/C++: often used for memory-mapped I/O or variables shared with interrupts to prevent compiler from optimizing away access.
C/C++:常用于内存映射 I/O 或与中断共享的变量,以防止编译器优化掉访问。
118. What is the Karat Coding Screen like for Atlassian?
Atlassian 的 Karat 编程筛选是怎样的?
- 知识点: 操作系统与网络 / 行为与软技能 (主题: interviewing;标签: Interview Process)
- 类型: behavioral | 难度: medium | 子类型: scenario
- 分类: general
- 公司: Atlassian
- id: 6979de4fc8f1f94b6462c731 | 官方: 是 | 付费: 否
答案:
通常 60 分钟线上面试,由第三方工程师按 Atlassian rubric 评估。一般包含两道中等算法题 + 调试/小型设计题。重点不仅是做对,还要代码可读、可测试、效率合理,并能清晰讲出取舍与边界情况。
119. What is included in the Virtual Loop at Atlassian?
Atlassian 的 Virtual Loop 包含哪些内容?
- 知识点: 操作系统与网络 / 行为与软技能 (主题: interviewing;标签: Interview Process)
- 类型: behavioral | 难度: medium | 子类型: scenario
- 分类: general
- 公司: Atlassian
- id: 6979de4fc8f1f94b6462c734 | 官方: 是 | 付费: 否
答案:
通常包含多轮:2 轮 Coding、1 轮 System Design、1 轮 Values。Coding 可能要求实现数据结构或解决更贴近业务的场景题;System Design 强调扩展性、可靠性、监控与取舍。
120. How does the Hiring Bar Review work at Atlassian?
Atlassian 的招聘标准审查是如何运作的?
- 知识点: 操作系统与网络 / 行为与软技能 (主题: interviewing;标签: Interview Process)
- 类型: behavioral | 难度: medium | 子类型: scenario
- 分类: general
- 公司: Atlassian
- id: 6979de4fc8f1f94b6462c737 | 官方: 是 | 付费: 否
答案:
面试官会提交校准后的反馈与 P-level 评估信号;独立的 hiring committee 汇总评审后决定最终级别与 offer 结果。根据你展示的影响范围与技术深度,可能出现上/下调级别的情况。
121. Python 的内存是如何管理的?
- 知识点: 操作系统与网络 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 / 编程语言基础 (主题: python, system-design;标签: python, gc, heap)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695b5e597fd56f69a88e88b8 | 官方: 是 | 付费: 否
答案:
TL;DRPython 使用私有堆管理对象,通过引用计数 + 垃圾回收处理内存释放。
机制- 对象存放在 Python private heap
- 引用计数为主,循环引用由 GC 处理
- 内存分配由解释器的内存管理器负责
122. Java 中 static 变量(static variable)与 volatile 变量(volatile variable)有什么区别?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java;标签: java, static, volatile, memory-model)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695cc0361da553795622a8eb | 官方: 是 | 付费: 否
答案:
TL;DR题目原文仅提供了对比图示。
123. 谈谈多线程(Multi-threading)。
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: multithreading, thread, cpu-performance, parallelism)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695ccbc41da5537956248fb6 | 官方: 是 | 付费: 否
答案:
TL;DR线程(Thread)是程序中的单一顺序控制流;多线程(Multi-threading)通过让多个线程并发执行提升 CPU 利用率,使多个请求或任务可同时处理。
线程(Thread)被定义为程序内部单一、顺序的控制流。它不是程序本身,不能独立运行。在运行中的程序里,线程需要占用一部分资源,例如执行栈(Execution Stack)和程序计数器(Program Counter)等,并且线程中的代码只在该上下文中有效。单线程(Single-threading)只有一个执行点,即一次只能处理一个请求。
多线程(Multi-threading)是一种用于提升 CPU 性能的方式。通过多线程,多个用户可以同时管理程序,或者同一用户可以同时管理多个请求。多线程通过操作系统支持的多个进程/线程并发执行实现。
例如:浏览器(Browser)通常有多个线程同时运行——你在滚动页面的同时可以下载文件、听音乐、后台打印等。
124. Java 中的死锁(Deadlock)是什么?如何避免?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java;标签: deadlock, java, locks, multithreading)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695ccbc41da5537956248fd9 | 官方: 是 | 付费: 否
答案:
TL;DR死锁(Deadlock)发生在多线程相互等待锁资源时,导致永久阻塞。可通过避免嵌套锁(Nested Lock)、设置锁超时(Lock Timeout)、避免不必要锁、使用锁升级(Lock Escalation)等方式降低风险。
死锁(Deadlock)是 Java 中一种线程互相等待资源的情况,通常发生在多线程环境下。可以通过以下方式避免死锁:
避免嵌套锁(Nested Lock):如果已经把锁给了一个线程,就避免再把同一资源锁交给其他线程导致循环等待。
使用锁超时(Lock Timeout):为线程设置等待锁的时间,避免无限等待。
避免不必要的锁:不必要的锁会增加死锁风险,应尽量减少。
使用锁升级(Lock Escalation):把多个锁合并为更少的锁,从而降低死锁风险。
125. 在全球分布式排行榜系统(Global Distributed Leaderboard System)中,玩家更新分数(Score Update)的完整流程应该如何设计?请说明关键组件与写入路径(Write Path)。
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: leaderboard, score-update, geo-replication, active-active, websocket)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695df7bb1da553795635d7ff | 官方: 是 | 付费: 否
答案:
TL;DR高可用全球排行榜(Global Leaderboard)写入通常采用全局负载均衡器(Global Load Balancer)+ 多数据中心(Active-Active) + Redis 有序集合(Sorted Set)写入 + 数据库异步落盘(Write-behind)。客户端通过 WebSocket 发送更新,服务端优先写缓存(Redis)以保证实时性,再由 Serverless 函数(Serverless Function)/异步任务写入关系型数据库(Relational Database)确保持久化。
关键设计点- 全球负载均衡(Global Load Balancer):将请求路由到最近的数据中心,降低延迟。
- 无状态服务(Stateless Web Server):多机房复制部署,支持水平扩展。
- Redis Sorted Set:用于实时写入和排序,快速得到 TopN / Rank。
- 关系型数据库(RDBMS):用于持久化与复杂分析查询。
- Active-Active Geo-Replication:缓存与数据库都支持跨地域双活,使每个机房都能接收写入。
- Write-behind Cache:先写缓存,后异步写数据库(减少写入瓶颈)。
写入流程(Score Update Workflow)- 客户端创建 WebSocket 连接到负载均衡器(Load Balancer),用于实时通信。 - Load Balancer 将请求转发到最近的数据中心(Geo routing)。
- 服务端将分数更新写入 Redis Sorted Set(例如 ZINCRBY)。
- 通过 Serverless Function / 异步任务,将变更使用写后(write-behind)模式落盘到关系型数据库。
为什么这样做?- Redis 先写:保证实时榜单立即可读,延迟低。 - 数据库后写:保证持久化与审计/统计能力,减少同步写入压力。
- 跨地域双活:降低跨洲延迟,避免单区域故障导致写入不可用。
126. 如何从排行榜系统中读取排行榜(Leaderboard)数据(读取流程(Read Workflow))?如果发生缓存未命中(Cache Miss)应该怎么处理?
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: read-through, cache-miss, websocket, thundering-herd)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695df7bb1da553795635d808 | 官方: 是 | 付费: 否
答案:
TL;DR读取流程通常是 WebSocket → 全局负载均衡器(Global LB) → 就近机房 → Redis 查询。在缓存命中时直接返回;发生缓存未命中(cache miss)时通过直读(read-through)查询关系型数据库(Relational Database)并回填缓存,同时需要防止惊群效应(thundering herd)。
读取流程(Retrieve Workflow)- 客户端建立 WebSocket 与负载均衡器(Load Balancer)的连接。
- Load Balancer 将请求路由到最近的数据中心。
- Serverless Function / 服务端访问 Redis Sorted Set 获取排行榜数据。
- 若 Redis 未命中,则使用 read-through cache pattern 查询关系型数据库,并将结果写回 Redis。
缓存未命中(Cache Miss)处理策略- 直读(Read-through):由服务端负责读数据库(DB)并回填缓存(cache)。 - 额外缓存层:在 DB 前增加缓存层以缓解集中访问。
- 防止 Thundering Herd:使用锁、请求合并、或者热点 key 预热。
实时更新榜单变化可通过 WebSocket 实时推送到客户端;客户端也可只订阅特定排行榜(leaderboard)并以规则引擎(Rule Engine)过滤更新。
127. 一个可扩展通知系统(Notification System)的高层架构应包含哪些组件?每个组件负责什么?
- 知识点: 操作系统与网络 / 算法与数据结构 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: notification-service, user-preferences, scheduler, queue, channel-processors, storage)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dfe121da5537956367903 | 官方: 是 | 付费: 否
答案:
TL;DR典型架构包括:通知服务(Notification Service)(入口 API + 校验 + 入队)、用户偏好服务(User Preference Service)(渠道偏好/退订/频率限制)、调度服务(Scheduler Service)(定时通知存储与触发)、通知队列(Notification Queue)(解耦与削峰,支持投递语义)、渠道处理器(Channel Processors)(按渠道消费发送并重试)、数据库/存储(Database/Storage)(偏好、日志、内容、附件等存储)。
组件职责- 通知服务(Notification Service):接收请求、鉴权校验、决定是否需要定时、将消息推送到队列。
- User Preference Service:存储用户渠道偏好、opt-in/opt-out、免打扰、每日限额等并执行限流规则。
- Scheduler Service:存储 scheduled notifications,在到达时间点后将消息送入队列。
- Notification Queue:缓冲与解耦,削峰填谷;可配置 at-least-once 或 exactly-once。
- Channel Processors:按渠道消费消息,调用第三方(SES/Twilio/FCM/APNs),失败重试与 DLQ。
- Database/Storage:存储用户偏好、通知内容、scheduled 通知、投递日志、附件(S3)等。
128. 为什么要为每个渠道设置独立的渠道处理器(Channel Processor)(如电子邮件(Email)/短信(SMS)/推送(Push)/应用内(In-app))?它们如何实现独立扩缩容、失败重试以及死信队列(DLQ)?
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: channel-processor, email, sms, push, in-app, retries, dlq, asynchronous-processing)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dfe121da553795636790f | 官方: 是 | 付费: 否
答案:
TL;DR按渠道拆分处理器(processor)可以实现异步处理与独立扩缩容:每个处理器(processor)只消费自己主题(topic)的消息并对接对应第三方供应商,失败时用指数退避(exponential backoff)重试,超过重试次数后将消息送入死信队列(DLQ)便于人工审查和补偿。
为什么要拆分- 不同渠道吞吐、延迟与失败特性不同(短信(SMS) vs 电子邮件(Email) vs 推送(Push))。
- 可独立扩缩容:某个渠道高峰时只扩容该 processor。
- 隔离故障:某个供应商故障不会影响其它渠道处理。
处理方式- 每个渠道一个主题(topic):电子邮件主题(Email Topic) / 短信主题(SMS Topic) / 推送主题(Push Topic) / 应用内主题(In-app Topic)。 - Processor 作为 consumer 拉取消息并调用对应 provider(SES/Twilio/FCM/APNs)。
- 失败重试:使用 exponential backoff。
- 超过最大重试次数:进入 DLQ,管理员可手动处理。
129. 分布式计数器(Distributed Counter)在高层工作原理上包含哪些关键机制?为什么通常会使用 WebSocket、心跳(heartbeat)以及无冲突复制数据类型(CRDT)计数器?
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design;标签: websocket, heartbeat, crdt, real-time, presence, gateway)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695dff721da55379563694ae | 官方: 是 | 付费: 否
答案:
TL;DR分布式计数器(distributed counter)通常由网关(gateway)通过 WebSocket 实时推送计数给客户端;通过heartbeat(心跳)清理失活连接保证计数正确;使用支持并发更新和最终一致的 CRDT(Conflict-free Replicated Data Type)计数器(counter)数据类型在多节点环境下合并计数。
关键机制- Gateway(网关) + WebSocket:网关(gateway)服务器通过 WebSocket 将计数实时展示给用户,适合频繁更新的实时场景。
- Heartbeat draining:通过心跳检测失活连接,及时回收连接并触发计数递减,避免“幽灵在线用户”。
- CRDT counter:在分布式数据库中使用 CRDT 计数器数据类型,使多个节点的增减操作能够在最终一致下安全合并。
为什么这样选- WebSocket:低延迟、双向通信,适合实时在线人数。 - Heartbeat:解决断网/异常退出导致无法 decrement 的问题。
- CRDT:天然支持冲突合并与最终一致,避免复杂的分布式锁/事务。
130. P2P(Peer-to-Peer)网络如何实现 peer discovery(节点发现)?DHT(Distributed Hash Table)的作用是什么?
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design, networking;标签: peer-discovery, dht, routing, self-organizing)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695e0de81da553795637df41 | 官方: 是 | 付费: 否
答案:
TL;DRP2P 的 peer discovery(节点发现)需要解决两个问题:我该连接谁?资源在哪里? 常见方式包括:中心目录(tracker)、DHT(Distributed Hash Table)、peer exchange(节点交换)。DHT 让节点在去中心化条件下完成资源定位与路由。
常见发现机制- Centralized directory / Tracker(中心目录/追踪器):通过一个中心服务记录 peer(节点)列表(易用但仍有中心依赖)。
- DHT(Distributed Hash Table):把资源 key 映射到负责的节点集合,节点通过路由算法查找 key 所在 peer(去中心化、可扩展)。
- Peer exchange:peer 之间互相交换已知节点列表,增强网络连通性。
DHT 的核心作用- 去中心化索引:无需中心服务器也能找到资源所在节点。 - 可扩展路由:通过结构化拓扑(如 consistent hashing)实现高效查找。
- 抗 churn:节点上下线时,路由表自动调整。
131. P2P(Peer-to-Peer)系统在设计上如何处理节点 churn(频繁上下线)与性能波动?你会采用哪些策略提升稳定性?
- 知识点: 操作系统与网络 / 系统设计/架构 / UI/UX 设计 (主题: system-design, networking;标签: churn, replication, redundancy, overlay-network, stability)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 695e0de81da553795637df4a | 官方: 是 | 付费: 否
答案:
TL;DRchurn(节点波动)会导致资源不可用与路由不稳定。P2P 系统通常通过冗余、多副本、健康探测、快速重连、拓扑自修复来提升稳定性。
常用策略- Replication & Redundancy(复制与冗余):对资源/索引做多副本存储,避免单 peer(节点)下线导致资源丢失。
- Health checks / Heartbeat:探测 peer 存活并及时更新路由表。
- Neighbor set maintenance:维护多个邻居节点列表,断线时快速切换。
- Adaptive routing:根据延迟/带宽动态选择更优 peer 路由。
- Caching:热门内容在更多 peer 缓存,提高可得性与吞吐。
- Backoff & rate limit:防止频繁重连造成风暴。
结果:即使节点频繁上下线,也能保持数据可用、路由可恢复、性能更稳定。
132. 48. 多线程中 synchronized(同步)锁升级的原理是什么?
- 知识点: 操作系统与网络 / 编程语言基础 (主题: java, concurrency, jvm;标签: synchronized, biased lock, lightweight lock, heavyweight lock)
- 类型: technical | 难度: hard | 子类型:
- 分类: backend
- id: 69672c36fa809e6d38a2aea0 | 官方: 是 | 付费: 否
答案:
答案synchronized(同步)锁升级原理:在锁对象的对象头(object header)里面有一个 threadid(线程ID)字段,在第一次访问的时候 threadid(线程ID)为空,jvm(Java虚拟机)让其持有偏向锁(biased lock),并将 threadid(线程ID)设置为其线程 id(标识符),再次进入的时候会判断 threadid(线程ID)是否与其线程 id(标识符)一致,如果一致则可以直接使用此对象,如果不一致,则升级偏向锁为轻量级锁(lightweight lock),通过自旋(spin)的方式尝试获取锁,获取成功之后,如果还是没有正常获取到要使用的对象,则就会尝试从轻量级锁升级为重量级锁(heavyweight lock),此过程就构成了 synchronized 锁的升级。
锁的升级的目的:锁升级是为了减低了锁带来的性能消耗。在 Java 6 之后优化 synchronized(同步)的实现方式,使用了偏向锁(biased lock)升级为轻量级锁(lightweight lock)再升级到重量级锁(heavyweight lock)的方式,从而减低了锁带来的性能消耗。
评论