Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

timer interrupt

cheriocherio Member Posts: 33
How do I set the 80x86 timer interrupt to interrupt a process after a
certain number of clock cycles.This is in connection with a simple
scheduling algorithm I wish to try out.Basically I wish to know the
functions for timer intterupt,like set time, start timer,stop timer
I am not sure if clock() in C is really for this purpose.

Comments

  • DariusDarius Member Posts: 1,666
    : How do I set the 80x86 timer interrupt to interrupt a process after a
    : certain number of clock cycles.

    A) The timer interrupt is constantly interrupting your process.
    B) You likely mean timer ticks as the timer doesn't necessarily care about clock cycles (though you could calculate the proper interrupt interval with your current clock speed).
    C) It should go without saying that there is no standard C way to do this (if there were then there would be standard C threading libraries).


    :This is in connection with a simple
    : scheduling algorithm I wish to try out.Basically I wish to know the
    : functions for timer intterupt,like set time, start timer,stop timer
    : I am not sure if clock() in C is really for this purpose.
    :
    clock() definitely is NOT for this purpose.

    First, you may want to think about making a simulator. That's typically easier to work with than the real thing, and it provides you much more control.

    However, if you want to implement the actual thing, then most modern OSes provide functions to do what you want (to a degree at least) or at the very worst provide threading utitilies that you could use to get the functionality you wanted. However, if you are using DOS then you'll need to roll-your-own code. Basically, you'll need to hook the timer interrupt, typically in the long (or not so long) run this will require you to have an assembly level understanding of the x86. However, many DOS C compilers provide functions that will install interrupt handlers for you and with that you could get (at least the beginning) of the functionality you want. If you want/need a shorter interval length than the default, 18.2 Hz, then you'll need to learn how to program the PIT. It isn't hard, but I don't feel like finding the necessary references for the specific ports and what not right now, so you can find them on your own.

    "We can't do nothing and think someone else will make it right."
    -Kyoto Now, Bad Religion

  • Chris BrownChris Brown USAMember Posts: 4,496 ✭✭

    _____ [ http://forcoder.org ] free ebooks and video tutorials about { PL/SQL JavaScript PHP Delphi R MATLAB C++ Visual Basic .NET C# Python Go Java Assembly Ruby C Scratch Visual Basic Swift Objective-C Perl ABAP VBScript ML F# Logo SAS Apex Bash Scheme Crystal Rust Fortran COBOL LabVIEW Dart Hack Lisp FoxPro D Prolog Lua Erlang Scala Kotlin Clojure Awk Julia Transact-SQL Ada Alice } ___________

Sign In or Register to comment.