Code Monkey home page Code Monkey logo

t9035100871 / sbunix Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rajesh5310/sbunix

0.0 1.0 0.0 6.58 MB

This project involved the development of a x86 64 bit operating system (SBUnix). It was developed in C and Assembly language. System was tested on QEMU which is a hosted hypervisor that performs hardware virtualization.The developed OS support for Context Switching, Memory management, File System, Terminal and Shell. System calls: COW fork, execvpe, sleep, malloc, exit,read, write, wait, waitpid,ls, ps, scanf etc. Memory management : 4 level Paging , virtual memory management in Ring 0 and Ring 3, Page-fault Handling etc. File-System : PCI bus and AHCI sata device controller interfacing and management, system calls (fread,fwrite, fseek, opendir, readir, mkdir) This project was undertaken as a part of CSE 506 Operating Systems course.

License: Other

Makefile 0.59% C 85.36% C++ 1.59% Assembly 1.04% Forth 11.32% Shell 0.10%

sbunix's Introduction

=====70 POINT PROJECT=====

==USEFUL TIPS==

For filesystem, use the disk named "hdd.img" in cse506 folder. Disk Image size is 20 MB

If new disk is to created, here are the following steps:

    1. Run the qemu command to create a 1 MB disk named "hdd.img" : qemu-img create hdd.img 20M 

    2. Insert superblock to that image using command : dd if=superblock of=hdd.img seek=1 conv=notrunc (superblock file is provided in the home directory, which is being generated using initialize_superblock.c)

    3. Now, the hdd.img is ready to be used by our OS. Run Qemu with following command : qemu-system-x86_64 -curses -cdrom $USER.iso -drive id=disk,file=hdd.img,if=none -device ahci,id=ahci -device ide-drive,drive=disk,bus=ahci.0 -gdb tcp::$1

    
For Shutdown : type shutdown on shell.
                            
For any queries, please contact SBUnix developers.

==SYSTEM CALLS==
/* File System Commands  */    
    READ()
    Syntax       :  read(file *file, uint64_t addr, char *buf )
    Description  :  Whenever called  this function reads the file in to the buffer 'buf'.
    Dependencies :  To open a file always use OPEN system call before reading and after the read is completed, close the file. This call returns -1 for the files whose WRONLY flag is set.
    return       :  This call returns the length of bytes read into the buffer or -1 if there is an error


    WRITE() 
    Syntax       :  int write(file *fd, char * buf, int size)
    Description  :  Whenever called it writes up to 'size' number of bytes into the file descriptor 'fd' from the buffer starting at 'addr'.
    Dependencies :  To open a file always use OPEN system call before reading and after the read is completed, close the file.
                    This call returns -1 for the files opened with O_RDONLY flag set. It cannot do any write operations on tarfs.
    return       :  This function retruns length of bytes written into the buffer or -1 on error
    
    MALLOC()
    Syntax       :  void *malloc(uint64_t size)
    Description  :  Whenever called the size of vma is increased by 'size'.
    return       :  This call returns the virtual address in heap
    
    FORK()
    Syntax       :  pid_t fork (void); 
    Description  :  Whenever called a child process is created. It returns pid = 0 for child process and non zero for parent process.
    return       :  This call returns the pid for parent process or 0 for the child  process.
    
    EXECVPE()
    Syntax       :  execvpe(char *file, char *argv[], char *envp[])
    Description  :  Whenever called a file along with any necessary arguments argv[] in the environment envp[] is executed.
    return       :  This call returns -1 on failure, and doesnot return anything on success
    
    WAIT()
    Syntax       :  wait(uint64_t status)
    Description  :  Whenever called, the parent waits for a child process to exit.
    return       :  This call returns -1 if the parent has no children.
    
    EXIT()
    Syntax       :  exit(int status)
    Description  :  Whenever called the calling process is terminated immediately.

    GETPID()
    Syntax       :  getpid()
    Description  :  Whenever called the process id of currently running process is returned.
    
    GETPPID()
    Syntax       :  getppid()
    Description  :  Whenever called the parent's process id of currently running process is returned.
    
    PS()
    Syntax       :  ps()
    Description  :  Whenever called the list of all currently running processes is returned.
    
    OPENDIR()
    Syntax       :  opendir(uint64_t* entry, uint64_t* directory)
    Description  :  Whenever called,a directory struct with list of all inode/files in it is returned.
    return       :  If an error occurs it will return directory struct with the values set to NULL.   
   
    READDIR()
    Syntax       :  readdir(DIR* node)
    Description  :  Whenver called iteratively, it will list contents in directory. 
    Dependencies :  Read directory system call is always followed after open directory system call.
    return       :  It will return the pointer to dirent structure .If end of directory is reached or an error occurs then it returns NULL.
 
    OPEN()
    Syntax       :  open(char* dir_path, uint64_t flags)
    Description  :  Whenever called, a file is opened and a file descriptor is returned. It opens files from 'tarfs' and disk depending on 'dir_path'.
    Dependencies :  The flags can be one of the following: 'O_CREAT', 'O_RDONLY', 'O_WRONLY', 'O_APPEND', 'O_TRUNC', 'O_RDWR'.
    return       :  This call returns file descriptor number open on a directory returns -1 as file descriptor.
    
    SLEEP()
    Syntax       :  sleep(int msec)
    Description  :  The state of the current task is changed to 'sleep' for 'msec' milliseconds.
    
    CLEAR()
    Syntax       :  clear()
    Description  :  Clears the screen.
    
    SEEK()
    Syntax       :  seek(uint64_t fd_type, int offset, int whence) 
    Description  :  When used it will move the current file pointer by offset number of bytes that is in the file.
    Dependencies :  whence can be SEEK_SET, SEEK_CUR, SEEK_END. Using this will provide the offset from start , current pointer or end of file.

    SHUTDOWN()
    Syntax       :  shutdown() 
    Description  :  This function is used to exit from all the processes. 

sbunix's People

Contributors

rajesh5310 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.