Question

In: Computer Science

How large is an operating system? Choose an example system, and count the lines of source...

How large is an operating system? Choose an example system, and count the lines of source code used for the kernel

Solutions

Expert Solution

Operating System (OS)
An OS is a system software which manages the hardware and software resources of a computer and gives the services for programs.

Kernel is the core of a OS, which controls everything in the system. Kernal is the first programs that loaded in the system after the boot loader loads. The kernal will handle the I/O requests from the software, converting it into executable instructions for the the processor. It will monitors the memory and also the peripherals such as keyboards, monitors, printers, keyboards and speakers.There will be critical code for the kernal which will be stored in the separate area of memory. The critical code will be s protected from other external accessing. The kernel has to handle the tasks such as executing different processes, controlling the hard disk, interrupts handling operations etc..

For this we have take an example of Windows Operating System

How large is a Windows operating system??

This question depends on different parameter: one important parameter is line of source code used by the kernal. The source code consists of comments, executable code, non executable codes, non delivered codes, statements etc..


Windows kernel have approximately 1.7 million lines of source code.

for example :

#include "console.h"
#include "serial.h"
#include "graphics.h"
#include "kmalloc.h"
#include "string.h"

struct console {
   struct_grhs *gphx;
   int x_size;
   int y_size;
   int x_post;
   int y_post;
   int on_off;
   int ref_cnt;
};

struct console console_root = {0};

static struct graphics_color bgmcolor = { 0, 0, 0 };
static struct graphics_color fgmcolor = { 255, 255, 255 };

static void console_reset( struct console *d )
{
   if(!d || !d->gphx) return;
   d->x_post = d->y_post = 0;
   d->x_size = gra_wid(d->gphx) / 8;
   d->y_size = gra_ht(d->gphx) / 8;
   d->on_off = 0;
   graphics_fgmcolor(d->gphx, fgmcolor);
   graphics_bgmcolor(d->gphx, bgmcolor);
   graphics_clear(d->gphx, 0, 0,gra_wid(d->gphx), gra_ht(d->gphx));
}

void console_heartbeat( struct console *d )
{
   char c = d->on_off ? ' ' : '_';
   graphics_char(d->gphx, d->x_post * 8, d->y_post * 8, c );
   d->on_off = !d->on_off;
}

int console_write( struct console *d, const char *data, int size )
{
   graphics_char(d->gphx, d->x_post * 8, d->y_post * 8, ' ');

   int i;
   for(i = 0; i < size; i++) {
       char c = data[i];
       switch (c) {
       case 13:
       case 10:
           d->x_post = 0;
           d->y_post++;
           break;
       case '\f':
           d->x_post = d->y_post = 0;
           d->x_size =gra_wid(d->gphx) / 8;
           d->y_size = gra_ht(d->gphx) / 8;
           graphics_fgmcolor(d->gphx, fgmcolor);
           graphics_bgmcolor(d->gphx, bgmcolor);
           graphics_clear(d->gphx, 0, 0,gra_wid(d->gphx), gra_ht(d->gphx));
           break;
       case '\b':
           d->x_post--;
           break;
       default:
           graphics_char(d->gphx, d->x_post * 8, d->y_post * 8, c);
           d->x_post++;
           break;
       }

       if(d->x_post < 0) {
           d->x_post = d->x_size - 1;
           d->y_post--;
       }

       if(d->x_post >= d->x_size) {
           d->x_post = 0;
           d->y_post++;
       }

       if(d->y_post >= d->y_size) {
           d->x_post = d->y_post = 0;
           d->x_size =gra_wid(d->gphx) / 8;
           d->y_size = gra_ht(d->gphx) / 8;
           graphics_fgmcolor(d->gphx, fgmcolor);
           graphics_bgmcolor(d->gphx, bgmcolor);
           graphics_clear(d->gphx, 0, 0,gra_wid(d->gphx), gra_ht(d->gphx));
       }

   }
   graphics_char(d->gphx, d->x_post * 8, d->y_post * 8, '_');
   return i;
}

void console_putchar( struct console *c, char ch )
{
   console_write(c,&ch,1);
}

void console_putstring( struct console *c, const char *str)
{
   console_write(c,str,strlen(str));
}

struct console *console_create(struct_grhs *g)
{
   struct console *c = kmalloc(sizeof(*c));
   c->gphx = graphics_add(g);
   c->ref_cnt = 1;
   console_reset(c);
   return c;
}

struct console *console_addref( struct console *c )
{
   c->ref_cnt++;
   return c;
}

void console_delete( struct console *c )
{
   c->ref_cnt--;
   if(c->ref_cnt==0) {
       graphics_delete(c->gphx);
       kfree(c);
   }
}

void console_size( struct console *c, int *x_size, int *y_size )
{
   *x_size = c->x_size;
   *y_size = c->y_size;
}

struct console * console_init(struct_grhs *g)
{
   console_root.gphx = g;
   console_reset(&console_root);
   console_putstring(&console_root,"\nconsole: initialized\n");
   return &console_root;
}

This is a 150 line of source having 3KB size


Related Solutions

"To decrease the cost of operating a lock in a large river, a new system of...
"To decrease the cost of operating a lock in a large river, a new system of operation is proposed. The system will cost $840,000 to design and build. It is estimated that it will have to be reworked every 7 years at a cost of $130,000. In addition, a one-time expenditure of $72,000 will have to be made at the end of the fifth year for a new type of gear that will not be available until then. Annual operating...
In Java: Write a program that will count the number of characters, words, and lines in...
In Java: Write a program that will count the number of characters, words, and lines in a file. Words are separated by whitespace characters. The file name should be passed as a command-line argument, as shown below. c:\exercise>java Exercise12_13 Loan.java File loan.java has 1919 characters 210 words 71 lines c:\exercise> Class Name: Exercise12_13
JAVA use the example and write program Choose five international source currencies to monitor. Each currency...
JAVA use the example and write program Choose five international source currencies to monitor. Each currency is referenced with a three letter ISO 4217 currency code. For example, the code for the U.S. Dollar currency is USD. Search online for these abbreviations with a search string such as "ISO 4217 Currency Codes." Place these currency codes in a text file. The following URL is a link to a CSV file that contains the exchange rate for a given source and...
Based on the source code below, add codes to count how many times array has been...
Based on the source code below, add codes to count how many times array has been access by this program in sorting the array using the insertion sort. Explain how did you count the number of array access on this code. Note that this program tests on 100 until 5000 integers, with increment of 100. import random #create randomized array of length 'length' from range 0 up to max def create_array(length=100, max=5000): return [random.randint(0,max) for _ in range(length)] #executes insertion...
In this assignment, you will use a LOC counting tool to count the lines of code...
In this assignment, you will use a LOC counting tool to count the lines of code of the tool itself. 1. There are several open source free tools for LOC counting such as CLOC and SLOC. 2. Run the tool to count the lines of code of the source files of the tool (usually in the src directory). 3. Submit a report which includes: a. Description of the tool 1. Name 2. Creator 3. Language(s) it is written 4. URL...
Chemoautotrophs use which of the following as their carbon source and their energy source? (Choose the...
Chemoautotrophs use which of the following as their carbon source and their energy source? (Choose the two correct answers.) a. Carbon dioxide b. Inorganic chemicals c. Light d. Organic compounds e. Synthesized compounds
Explain why spectral lines are useful in determining the chemical composition of their source.
Explain why spectral lines are useful in determining the chemical composition of their source.
Give one example how the the endocrine system work with the immune system?
Give one example how the the endocrine system work with the immune system?
What is an ‘operating system’ and what does it do? What is meant by the term ‘open source’ or ‘copyleft’ in reference to the GPL license that is distributed with most Linux operating systems?
What is an ‘operating system’ and what does it do? What is meant by the term ‘open source’ or ‘copyleft’ in reference to the GPL license that is distributed with most Linux operating systems? How do the business models of Linux-based companies differ from Microsoft with regards to intellectual property and customer service. When and if a Linux-based company (e.g. RedHat, Suse, Ubuntu, or Mint… etc) charges a fee for their operating systems, and the code is designated open source,...
Question 1 i. Explain briefly with an example how customer complaints can be a source of...
Question 1 i. Explain briefly with an example how customer complaints can be a source of new product idea ii. Using a phone’s battery to illustrate, explain briefly how the mean time between failures (MTBF) can be used as a measure of a product’s reliability
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT