EzDevInfo.com

operating-system interview questions

Top operating-system frequently asked interview questions

Why use Python's os module methods instead of executing shell commands directly?

I am trying to understand what is the motivation behind using Python's library functions for executing OS-specific tasks such as creating files/directories, changing file attributes, etc. instead of just executing those commands via os.system() or subprocess.call()?

For example, why would I want to use os.chmod instead of doing os.system("chmod...")?

I understand that it is more "pythonic" to use Python's available library methods as much as possible instead of just executing shell commands directly. But, is there any other motivation behind doing this from a functionality point of view?

I am only talking about executing simple one-line shell commands here. When we need more control over the execution of the task, I understand that using subprocess module makes more sense, for example.


Source: (StackOverflow)

What happens when a computer program runs?

I know the general theory but I can't fit in the details.

I know that a program resides in the secondary memory of a computer. Once the program begins execution it is entirely copied to the RAM. Then the processor retrive a few instructions (it depends on the size of the bus) at a time, puts them in registers and executes them.

I also know that a computer program uses two kinds of memory: stack and heap, which are also part of the primary memory of the computer. The stack is used for non-dynamic memory, and the heap for dynamic memory (for example, everything related to the new operator in C++)

What I can't understand is how those two things connect. At what point is the stack used for the execution of the instructions? Instructions go from the RAM, to the stack, to the registers?


Source: (StackOverflow)

Advertisements

What is private bytes, virtual bytes, working set?

I am using the perfmon windows utility to debug memory leaks in a process.

Perfmon explanation:

Working Set- Working Set is the current size, in bytes, of the Working Set of this process. The Working Set is the set of memory pages touched recently by the threads in the process. If free memory in the computer is above a threshold, pages are left in the Working Set of a process even if they are not in use. When free memory falls below a threshold, pages are trimmed from Working Sets. If they are needed they will then be soft-faulted back into the Working Set before leaving main memory.

Virtual Bytes- Virtual Bytes is the current size, in bytes, of the virtual address space the process is using. Use of virtual address space does not necessarily imply corresponding use of either disk or main memory pages. Virtual space is finite, and the process can limit its ability to load libraries.

Private Bytes- Private Bytes is the current size, in bytes, of memory that this process has allocated that cannot be shared with other processes.

Q1. Is it the Private Bytes which I should measure to be sure if the process is having any leaks as it does not involve any shared libraries and any leaks if happening will come from the process itself?

Q2. What is the total memory consumed by the process? Is it the Virtual Bytes or is it the sum of Virtual Bytes and Working Set

Q3. Is there any relation between Private Bytes, Working Set and Virtual Bytes.

Q4. Any tool which gives a better idea memory information?


Source: (StackOverflow)

Why is Linux called a monolithic kernel?

I read that Linux is a monolithic kernel. Does monolithic kernel mean compiling and linking the complete kernel code into an executable?

If Linux is able to support modules, why not break all the subsystems into modules and load them when necessary? In that case, the kernel doesn't have to load all modules initially and could maintain an index of the functions in the module and load them when necessary.


Source: (StackOverflow)

What is an OS kernel ? How does it differ from an operating system? [closed]

I am not able to understand the difference between a kernel and an operating system. I do not see any difference between them. Is the kernel an operating system?


Source: (StackOverflow)

How do you write a basic operating system? [closed]

Let me know how I can create a basic operating system.

What books do you recommend?


Source: (StackOverflow)

Detect Windows 7 in .net

How can I detect Windows 7 (versions) in .net?

What code can I use?


Source: (StackOverflow)

Spinlock versus Semaphore

What is the basic differences between Semaphores & Spinlock? & In what best situations or conditions, we can use these.


Source: (StackOverflow)

What are some resources for getting started in operating system development? [closed]

One thing I've always wanted to do is develop my very own operating system (not necessarily fancy like Linux or Windows, but better than a simple boot loader which I've already done).

I'm having a hard time finding resources/guides that take you past writing a simple "Hello World" OS.

I know lots of people will probably recommend I look at Linux or BSD; but the code base for systems like that is (presumably) so big that I wouldn't know where to start.

Any suggestions?

Update: To make it easier for people who land on this post through Google here are some OS development resources:

Other resources:

I found a nice resource named MikeOS, "MikeOS is a learning tool to demonstrate how simple OSes work. It uses 16-bit real mode for BIOS access, so that it doesn't need complex drivers"

Updated 11/14/08

I found some resources at Freebyte's Guide to...Free and non-free Operating Systems that links to kits such as OSKit and ExOS library. These seem super useful in getting started in OS development.

Updated 2/23/09

Ric Tokyo recommended nanoos in this question. Nanoos is an OS written in C++.

Updated 3/9/09

Dinah provided some useful Stack Overflow discussion of aspiring OS developers: Roadblocks in creating a custom operating system discusses what pitfalls you might encounter while developing an OS and OS Development is a more general discussion.

Updated 7/9/09

LB provided a link to the Pintos Project, an education OS designed for students learning OS development.

Updated 7/27/09 (Still going strong!)

I stumbled upon an online OS course from Berkley featuring 23 lectures.

TomOS is a fork of MikeOS that includes a little memory manager and mouse support. As MikeOS, it is designed to be an educational project. It is written in NASM assembler.

Updated 8/4/09

I found the slides and other materials to go along with the online Berkeley lectures listed above.

Updated 8/23/09

All questions tagged osdev on stackoverflow

OS/161 is an academic OS written in c that runs on a simulated hardware. This OS is similar in Nachos. Thanks Novelocrat!

tangurena recommends http://en.wikipedia.org/wiki/MicroC/OS-II, an OS designed for embedded systems. There is a companion book as well.

Linux Kernel Development by Robert Love is suggested by Anders. It is a "widely acclaimed insider's look at the Linux kernel."

Updated 9/18/2009

Thanks Tim S. Van Haren for telling us about Cosmos, an OS written entirely in c#.

tgiphil tells us about Managed Operating System Alliance (MOSA) Framework, "a set of tools, specifications and source code to foster development of managed operating systems based on the Common Intermediate Language."

Update 9/24/2009

Steve found a couple resources for development on windows using Visual Studio, check out BrokenThorn's guide setup with VS 2005 or OSDev's VS Section.

Update 1/20/2012

A set of tutorials aims to take you through programming a simple UNIX-clone operating system for the x86 architecture. JamesM's kernel development tutorials

Updated 9/5/2012

kerneltrap.org is no longer available. The linux kernel v0.01 is available from kernel.org

Updated 12/21/2012 A basic OS development tutorial designed to be a semester's project. It guides you through to build an OS with basic components. Very good start for beginners. Related paper. Thanks Srujan!

Updated 11/15/2013

Writing a Simple Operating System From Scratch. Thanks James Moore!

Updated 12/8/2013

How to make a computer operating system Thanks ddtoni!

Updated 3/18/2014

ToAruOS an OS built mostly from scratch, including GUI


Source: (StackOverflow)

What is Application Binary Interface (ABI)?

I never clearly understood what is an ABI. I'm sorry for such a lengthy question. I just want to clearly understand things. Please don't point me to wiki article, If could understand it, I wouldn't be here posting such a lengthy post.

This is my mindset about different interfaces:

TV remote is an interface between user and TV. It is an existing entity but useless (doesn't provide any functionality) by itself. All the functionality for each of those buttons on the remote is implemented in the Television set.

Interface: It is a "existing entity" layer between the functionality and consumer of that functionality. An, interface by itself is doesn't do anything. It just invokes the functionality lying behind.

Now depending on who the user is there are different type of interfaces.

Command Line Interface(CLI) commands are the existing entities, consumer is the user and functionality lies behind.

functionality: my software functionality which solves some purpose to which we are describing this interface.

existing entities: commands

consumer: user

Graphical User Interface(GUI) window,buttons etc.. are the existing entities, again consumer is the user and functionality lies behind.

functionality: my software functionality which solves some purpose to which we are describing this interface.

existing entities: window,buttons etc..

consumer: user

Application Programming Interface(API) functions or to be more correct, interfaces (in interfaced based programming) are the existing entities, consumer here is another program not a user. and again functionality lies behind this layer.

functionality: my software functionality which solves some purpose to which we are describing this interface.

existing entities: functions, Interfaces(array of functions).

consumer: another program/application.

Application Binary Interface (ABI) Here is my problem starts.

functionality: ???

existing entities: ???

consumer: ???

  • I've wrote few softwares in different languages and provided different kind of interfaces (CLI, GUI, API) but I'm not sure, if I ever, provided any ABI.

Wikipedia says:

ABIs cover details such as

  • data type, size, and alignment;
  • the calling convention, which controls how functions' arguments are passed and return values retrieved;
  • the system call numbers and how an application should make system calls to the operating system;

Other ABIs standardize details such as

  • the C++ name mangling,[2] .
  • exception propagation,[3] and
  • calling convention between compilers on the same platform, but do not require cross-platform compatibility.
  • Who needs these details? Please don't say, OS. I know assembly programming. I know how linking & loading works. I know what exactly happens inside.

  • Where did C++ name mangling come in between? I thought we are talking at the binary level. Where did languages come in between?

anyway, I've downloaded the [PDF] System V Application Binary Interface Edition 4.1 (1997-03-18) to see what exactly it contains. Well, most of it didn't make any sense.

  • Why does it contain 2 chapters (4th & 5th) which describe the ELF file format.Infact, these are the only 2 significant chapters that specification. Rest of all the chapters "Processor Specific". Anyway, I thought that it is completely different topic. Please don't say that ELF file format specs are the ABI. It doesn't qualify to be Interface according to the definition.

  • I know, since we are talking at such low level it must be very specific. But I'm not sure how is it "Instruction Set Architecture(ISA)" specific?

  • Where can I find MS Window's ABI?

So, these are the major queries that are bugging me.


Source: (StackOverflow)

How do I set a Windows scheduled task to run in the background? [closed]

Does anyone know how to set a scheduled task to run in background using Windows Task Scheduler?
There doesn't seem to be any option to do this.


Source: (StackOverflow)

Locking Executing Files: Windows does, Linux doesn't. Why?

I noticed when a file is executed on Windows (.exe or .dll), it is locked and cannot be deleted, moved or modified.

Linux, on the other hand, does not lock executing files and you can delete, move, or modify them.

Why does Windows lock when Linux does not? Is there an advantage to locking?


Source: (StackOverflow)

What is the difference between the kernel space and the user space?

What is the difference between the kernel space and the user space? Do kernel space, kernel threads, kernel processes and kernel stack mean the same thing? Also, why do we need this differentiation?


Source: (StackOverflow)

What is the difference between user variables and system variables?

What is the difference between user variables such as PATH, TMP, etc. and system variables?

I accidentally deleted the user variable PATH. What am I supposed to do? Thanks in advance.


Source: (StackOverflow)

How do I check OS with a preprocessor directive?

I need my code to do different things based on the operating system on which it gets compiled. I'm looking for something like this:

#ifdef OSisWindows
  //define something for Windows
#else
  //define it for a Unix machine
#endif

Is there a way to do this? Is there a better way to do the same thing?


Source: (StackOverflow)