• Guest
HabraHabr
  • Main
  • Users

  • Development
    • Programming
    • Information Security
    • Website development
    • JavaScript
    • Game development
    • Open source
    • Developed for Android
    • Machine learning
    • Abnormal programming
    • Java
    • Python
    • Development of mobile applications
    • Analysis and design of systems
    • .NET
    • Mathematics
    • Algorithms
    • C#
    • System Programming
    • C++
    • C
    • Go
    • PHP
    • Reverse engineering
    • Assembler
    • Development under Linux
    • Big Data
    • Rust
    • Cryptography
    • Entertaining problems
    • Testing of IT systems
    • Testing Web Services
    • HTML
    • Programming microcontrollers
    • API
    • High performance
    • Developed for iOS
    • CSS
    • Industrial Programming
    • Development under Windows
    • Image processing
    • Compilers
    • FPGA
    • Professional literature
    • OpenStreetMap
    • Google Chrome
    • Data Mining
    • PostgreSQL
    • Development of robotics
    • Visualization of data
    • Angular
    • ReactJS
    • Search technologies
    • Debugging
    • Test mobile applications
    • Browsers
    • Designing and refactoring
    • IT Standards
    • Solidity
    • Node.JS
    • Git
    • LaTeX
    • SQL
    • Haskell
    • Unreal Engine
    • Unity3D
    • Development for the Internet of things
    • Functional Programming
    • Amazon Web Services
    • Google Cloud Platform
    • Development under AR and VR
    • Assembly systems
    • Version control systems
    • Kotlin
    • R
    • CAD/CAM
    • Customer Optimization
    • Development of communication systems
    • Microsoft Azure
    • Perfect code
    • Atlassian
    • Visual Studio
    • NoSQL
    • Yii
    • Mono и Moonlight
    • Parallel Programming
    • Asterisk
    • Yandex API
    • WordPress
    • Sports programming
    • Lua
    • Microsoft SQL Server
    • Payment systems
    • TypeScript
    • Scala
    • Google API
    • Development of data transmission systems
    • XML
    • Regular expressions
    • Development under Tizen
    • Swift
    • MySQL
    • Geoinformation services
    • Global Positioning Systems
    • Qt
    • Dart
    • Django
    • Development for Office 365
    • Erlang/OTP
    • GPGPU
    • Eclipse
    • Maps API
    • Testing games
    • Browser Extensions
    • 1C-Bitrix
    • Development under e-commerce
    • Xamarin
    • Xcode
    • Development under Windows Phone
    • Semantics
    • CMS
    • VueJS
    • GitHub
    • Open data
    • Sphinx
    • Ruby on Rails
    • Ruby
    • Symfony
    • Drupal
    • Messaging Systems
    • CTF
    • SaaS / S+S
    • SharePoint
    • jQuery
    • Puppet
    • Firefox
    • Elm
    • MODX
    • Billing systems
    • Graphical shells
    • Kodobred
    • MongoDB
    • SCADA
    • Hadoop
    • Gradle
    • Clojure
    • F#
    • CoffeeScript
    • Matlab
    • Phalcon
    • Development under Sailfish OS
    • Magento
    • Elixir/Phoenix
    • Microsoft Edge
    • Layout of letters
    • Development for OS X
    • Forth
    • Smalltalk
    • Julia
    • Laravel
    • WebGL
    • Meteor.JS
    • Firebird/Interbase
    • SQLite
    • D
    • Mesh-networks
    • I2P
    • Derby.js
    • Emacs
    • Development under Bada
    • Mercurial
    • UML Design
    • Objective C
    • Fortran
    • Cocoa
    • Cobol
    • Apache Flex
    • Action Script
    • Joomla
    • IIS
    • Twitter API
    • Vkontakte API
    • Facebook API
    • Microsoft Access
    • PDF
    • Prolog
    • GTK+
    • LabVIEW
    • Brainfuck
    • Cubrid
    • Canvas
    • Doctrine ORM
    • Google App Engine
    • Twisted
    • XSLT
    • TDD
    • Small Basic
    • Kohana
    • Development for Java ME
    • LiveStreet
    • MooTools
    • Adobe Flash
    • GreaseMonkey
    • INFOLUST
    • Groovy & Grails
    • Lisp
    • Delphi
    • Zend Framework
    • ExtJS / Sencha Library
    • Internet Explorer
    • CodeIgniter
    • Silverlight
    • Google Web Toolkit
    • CakePHP
    • Safari
    • Opera
    • Microformats
    • Ajax
    • VIM
  • Administration
    • System administration
    • IT Infrastructure
    • *nix
    • Network technologies
    • DevOps
    • Server Administration
    • Cloud computing
    • Configuring Linux
    • Wireless technologies
    • Virtualization
    • Hosting
    • Data storage
    • Decentralized networks
    • Database Administration
    • Data Warehousing
    • Communication standards
    • PowerShell
    • Backup
    • Cisco
    • Nginx
    • Antivirus protection
    • DNS
    • Server Optimization
    • Data recovery
    • Apache
    • Spam and antispam
    • Data Compression
    • SAN
    • IPv6
    • Fidonet
    • IPTV
    • Shells
    • Administering domain names
  • Design
    • Interfaces
    • Web design
    • Working with sound
    • Usability
    • Graphic design
    • Design Games
    • Mobile App Design
    • Working with 3D-graphics
    • Typography
    • Working with video
    • Work with vector graphics
    • Accessibility
    • Prototyping
    • CGI (graphics)
    • Computer Animation
    • Working with icons
  • Control
    • Careers in the IT industry
    • Project management
    • Development Management
    • Personnel Management
    • Product Management
    • Start-up development
    • Managing the community
    • Service Desk
    • GTD
    • IT Terminology
    • Agile
    • Business Models
    • Legislation and IT-business
    • Sales management
    • CRM-systems
    • Product localization
    • ECM / EDS
    • Freelance
    • Venture investments
    • ERP-systems
    • Help Desk Software
    • Media management
    • Patenting
    • E-commerce management
    • Creative Commons
  • Marketing
    • Conferences
    • Promotion of games
    • Internet Marketing
    • Search Engine Optimization
    • Web Analytics
    • Monetize Web services
    • Content marketing
    • Monetization of IT systems
    • Monetize mobile apps
    • Mobile App Analytics
    • Growth Hacking
    • Branding
    • Monetize Games
    • Display ads
    • Contextual advertising
    • Increase Conversion Rate
  • Sundry
    • Reading room
    • Educational process in IT
    • Research and forecasts in IT
    • Finance in IT
    • Hakatonas
    • IT emigration
    • Education abroad
    • Lumber room
    • I'm on my way

Writing OS: Multitasking

 3r3152. 3r3-31. Writing OS: Multitasking 3r33140.  3r3152. Good day, dear reader, most likely, you saw my previous article that you can write a working OS yourself in a relatively short period of time. Well, today we will talk about the implementation of multitasking in my OS.
3r33140.  3r3152. 3r33140.  3r3152. Well, you probably can't imagine a single-task OS in 201? that's why I decided to talk about the implementation of multitasking in my OS. And so, first - you need to decide on the type of multitasking, I chose preemptive. 3r33140.  3r3152. What is she like? Preemptive multitasking is a system for distributing the processing power of a processor between processes: each has its own time slice, each has its own priority. And the first problem is which quantum in length to choose, how to stop the process after the quantum expires? In fact, everything is easier than ever! We will use PIT with the initially set frequency of 10026 with interrupt kopecks per second, right there we solve another problem: we are already stopping the previous process. And so, let's start with PIT. 3r33140.  3r3152. 3r33140.  3r3152. 3r33132. PIT 3r3133. 3r33140.  3r3152. PIT - Programmable Interval Timer - a counter that, upon reaching a programmed number of increments, generates a signal. Also, with the help of this timer, you can squeak a squeak in a computer (the thing that squeaks after passing the test devices). And so, he believes with a frequency of 1193182 hertz, this means that we need to program it for 119 (1193182/119 is approximately equal to 10026). To do this, send 2 bytes to the port of the first generator, first the low byte, and then the high byte: 3r3-33140.  3r3152. 3r33140.  3r3152.
3r3108. unsigned short hz = 119; 3r3152. outportb (0x4? 0x34); 3r3152. outportb (0x4? (unsigned char) hz & 0xFF); //Low
outportb (0x4? (unsigned char) (hz 8) & 0xFF); //Hight, about 10026 times per second 3r3116. 3r33140.  3r3152. 3r33140.  3r3152. Now it’s worthwhile to start programming the interrupt from the PIT, it has IRQ ? and after PIC's remap it will be 0x20m. For the IRQ of the first PIC, I wrote this macro: 3r3-33140.  3r3152. 3r33140.  3r3152.
3r3108. //PIC # 0; port 0x20
#define IRQ_HANDLER (func) char func = 0x90; 3r3152. __asm ​​__ (# func ": npusha n call __" # func "n movb $ 0x2?
% al n outb% al, $ 0x20 n popa n iret n"); 3r3152. void _ ## func () 3r3116. 3r33140.  3r3152. 3r33140.  3r3152. 3r33132. Structure and processes
3r33140.  3r3152. And so, as you understand, we need to develop a structure for each process, as well as a structure that allows us to remember all my allocations of memory. 3r33140.  3r3152. This is what I have:
 3r3152.
3r3108. 3r3152. typedef struct _pralloc
{
void * addr; 3r3152. struct _pralloc * next; 3r3152.} processAlloc; 3r3152. typedef struct 3r3152. {
void * entry; 3r3152. processAlloc * allocs; 3r3152.} ELF_Process; 3r3152. typedef struct __attribute __ ((packed)) _E {3r3152. unsigned int eax; //4
unsigned int ebx; //8
unsigned int ecx; //12
unsigned int edx; //16
unsigned int ebp; //20
unsigned int esp; //24
unsigned int esi; //28
unsigned int edi; //32
unsigned int eflags; //36
unsigned int state; //40
void * startAddr; //44
void * currentAddr; //48
void * stack; //52
unsigned int sse[4 * 8]; //3r3152. unsigned int mmx[2 * 8]; //244
unsigned int priority; //248
unsigned int priorityL; //252
void * elf_process; //256
char ** argv; //260
unsigned int argc; //264
unsigned int runnedFrom; //268
char * workingDir; //272
unsigned int cs; //276 - pop is 4 byte in IRET
unsigned int ds; //280
} Process; 3r3152. 3r3115. 3r3116. 3r33140.  3r3152. 3r33140.  3r3152. First, we need to understand the following: we can somewhere at the global address, for example, by 0xDEAD, put the number of the current running process, then when executing any code we can be sure that we have the number of the currently running process, which means that when we call malloc, we know who we allocate memory for, and we can immediately add the address of the allocated memory to the allocs list. 3r33140.  3r3152.
3r3108. void addProcessAlloc (ELF_Process * p, void * addr)
{
void * z = p-> allocs; 3r3152. p-> allocs = malloc_wo_adding_to_process (sizeof (processAlloc)); 3r3152. p-> allocs-> addr = addr; 3r3152. p-> allocs-> next = z; 3r3152.} 3r3116. 3r33140.  3r3152. 3r33140.  3r3152. Well, we wrote the structure of the table with the description of the processes, what next, how to switch tasks? 3r33140.  3r3152. First I want to note that, for example, in the handler, local variables are stored on the stack, which means that after entering the handler, the compiler spoils us with esp. To prevent this from happening, we will create a variable with an absolute address, and before calling the handler, we will push ESP there. In the handler, we need to send the EOI to the first PIC and find the process to which we need to switch (I will not describe the priority mechanism: it is as simple as a traffic jam). Next - we need to save all the registers and flags of the current process, so immediately before putting ESP into a variable, we save all registers (including segment ones) onto the stack. In the handler itself, we very carefully need to remove them from the stack, also saving the flags and return address. I want to note that the stack grows up (ie, ESP decreases), this means that the last register that you saved to the stack will be at ESP, the penultimate - ESP +? and so on:
 3r3152. 3r33140.  3r3152. Now it remains for us to shove the registers of the values ​​of the process registers to which we switched and execute IRET. Profit! 3r33140.  3r3152. 3r33140.  3r3152. 3r33132. Running processes 3r3133. 3r33140.  3r3152. When starting the process, we just need to allocate a stack for the process, after which we put argc and argv into it, the address of the function that will be given control after the process is completed. It is also necessary to set the processor flags to the desired value, for example, for my OS it is 0x21? you can read about the register of flags on wikipedia. 3r33140.  3r3152. 3r33140.  3r3152. Finally, I would like to wish you success, in a short time I will write about the work with memory and other articles of interest to you. 3r33140.  3r3152. Good luck, and ethical hacking! 3r3148. 3r3152. 3r3152. 3r3145. ! function (e) {function t (t, n) {if (! (n in e)) {for (var r, a = e.document, i = a.scripts, o = i.length; o-- ;) if (-1! == i[o].src.indexOf (t)) {r = i[o]; break} if (! r) {r = a.createElement ("script"), r.type = "text /jаvascript", r.async =! ? r.defer =! ? r.src = t, r.charset = "UTF-8"; var d = function () {var e = a.getElementsByTagName ("script")[0]; e.parentNode.insertBefore (r, e)}; "[object Opera]" == e.opera? a.addEventListener? a.addEventListener ("DOMContentLoaded", d,! 1): e.attachEvent ("onload", d ): d ()}}} t ("//mediator.mail.ru/script/2820404/"""_mediator") () (); 3r3146. 3r3152. 3r3148. 3r3152. 3r3152. 3r3152. 3r3152.

It may be interesting

  • Comments
  • About article
  • Similar news
sohail khatri 28 September 2019 13:49
Essay writer service is quite good under the buy masters dissertation if you ask me. I have availed their services and they have provided with amazing content for the assigned projects.
sk production 25 January 2020 14:57
If you are looking for essay writers for hire then I would suggest you go for Accounting coursework help. They not only have excellent writers to work for you but they also charge less.
sohail khatri 26 January 2020 10:31
If you wish to hire essay writer, I would definitely recommend opting for SAT prep because of how affordable and good quality their services are.
cyber security research paper 8 February 2020 11:25
Finding good expert writing expert in the market is tough. This is the reason why I reached out to cyber security research paper and their services did help me out a lot.
wal mart 18 February 2020 06:11
I hope that there will be miracles, heal the broken heart is crying and sad. The sky is still divided night light right then we broke up already, so our love circle is like that.
walmart near me

weber

Author

18-10-2018, 03:37

Publication Date

System Programming / High performance / IT Standards

Category
  • Comments: 5
  • Views: 377
C vs Go cycles and simple math
Chinese artificial sun
Introduction to complex numbers
How to set up or disable lint in the
To the question of speed and its
10 physical facts that you should have
Write a comment
Name:*
E-Mail:


Comments
Global Dezigns is a Website Development Company in Karachi, Providing services of
website design in karachi
. We are delivering the best partnership across Pakistan. provides a complete range of web development services including web applications, website hosting and maintenance, domain registration, on-page search engine optimization, and website integration with social media platforms such as Facebook, Twitter, LinkedIn, Google Maps, and Google Local Directory. We believe we are well placed to take our knowledge and expertise to the logical next level with the latest web standards.  
  Show/hide text
https://www.globaldezigns.com/



Yesterday, 22:45

mike tomlin

This blog is really great. The information here will surely be of some help to me. Thanks!.mastering physics

Yesterday, 17:57

raymond weber

Coinyspace is the cryptocurrency community and trading forum where members can find any contributors of crypto ecosystem like currencies, exchanges & merchants. Check Out: Bitcoin Merchants
Yesterday, 16:57

noorseo

This is a great high resolution screen which you have shared for the users. Making a website is not an easy task but managing a good website is really a hard work. As far as this website is concerned, I am very happy.https://19216801.1
Yesterday, 16:01

nushra45

i'm satisfied to deem this make recognized Very beneficial for me, as it contains lot of advice. I usually favor to buttonhole The excellent and glad i found this count number in you assertion. thanks Subliminal Hypnosis
Yesterday, 14:56

jahangirkhatri

Adv
Website for web developers. New scripts, best ideas, programming tips. How to write a script for you here, we have a lot of information about various programming languages. You are a webmaster or a beginner programmer, it does not matter, useful articles will help to make your favorite business faster.

Login

Registration Forgot password