• since ya'll are asking.

    From Chris Hoppman@1:129/305 to All on Thursday, December 11, 2003 13:21:44
    Since ya'll are asking for someone to help. Maybe you can help me with a problem I am having with a source code I am modifing.

    It has timeslices built into it, but the CPU usage is still in the upper limits (89-98%). I sorta remember something I have read and wantted to verify it. That the timeslices shouldn't be gave at anytime. Like say you do this.

    For A := 0 to 100 do
    begin
    {Do some stuff here}
    TimeSlice;
    end;

    It would do 100 timeslices back to back.

    I have read that you should time them to be at least 55 ms apart
    ( depending on the system ). That if you do like I did above it will accually make the application use more of the CPU.

    Maybe someone could explain to me all about Time Slices. Or point me in the direction of a place I can read up on them.

    Bluewolf

    --- Renegade v12-08.3 Alpha
    * Origin: The Titantic BBS Telnet - ttb.slyip.com (1:129/305)
  • From Jasen Betts@3:640/1042 to Chris Hoppman on Saturday, December 13, 2003 11:50:19
    Hi Chris.

    11-Dec-03 13:21:44, Chris Hoppman wrote to All


    Since ya'll are asking for someone to help. Maybe you can help me with a

    problem I am having with a source code I am modifing.

    It has timeslices built into it, but the CPU usage is still in the upper limits (89-98%). I sorta remember something I have read and wantted to verify
    it. That the timeslices shouldn't be gave at anytime. Like say you do this.

    For A := 0 to 100 do
    begin
    {Do some stuff here}
    TimeSlice;
    end;

    It would do 100 timeslices back to back.

    first off check the documentation for "timeslice" I don't find it
    documented as a standard part of TP

    What I'm guessing it does is inform a multitasker that the program is not
    busy so that the multitasker can dedicate more cpu effort to running other tasks. (AFAIK windows OS/2 and Dessqview all do that in slightly different ways (if you're using a dos compiler)

    I have read that you should time them to be at least 55 ms apart
    ( depending on the system ). That if you do like I did above it will accually make the application use more of the CPU.

    I don't see how it could cause more CPU usage than putting some form of
    delay loop between calls to timeslice.

    Maybe someone could explain to me all about Time Slices. Or point me in the direction of a place I can read up on them.

    OTOH if you want to delay for a long time there may be some sort of sleep procedure avaialable. (but your code suggests to me that you want to
    "do some stuff" between timeslices so probably you are doing it the best way.

    Bye <=-



    ---
    * Origin: Entropy isn't what it used to be. (3:640/1042)
  • From mark lewis@1:3634/12 to Chris Hoppman on Sunday, December 14, 2003 17:48:10
    Since ya'll are asking for someone to help.

    hehehe...

    Maybe you can help me with a problem I am having with
    a source code I am modifing.

    can only try...

    It has timeslices built into it, but the CPU usage is still in
    the upper limits (89-98%).

    what operating system, version and timeslice style?? all three are needed to be
    known... there are several ways of timeslicing... choosing the proper one depends on the operating system and in some cases, which version of the operating system...

    I sorta remember something I have read and wantted to verify
    it. That the timeslices shouldn't be gave at anytime.

    i'm not familiar with that...

    Like say you do this.

    For A := 0 to 100 do
    begin
    {Do some stuff here}
    TimeSlice;
    end;

    It would do 100 timeslices back to back.

    almost... {do some stuff here} would also take some time to do its thing...

    I have read that you should time them to be at least 55 ms
    apart ( depending on the system ). That if you do like I
    did above it will accually make the application use more of
    the CPU.

    dunno about using more of the cpu or not... and i can't really confirm them to be at least 55ms apart, either...

    Maybe someone could explain to me all about Time Slices. Or
    point me in the direction of a place I can read up on them.

    wow, i picked up a lot of my knowledge about them in numerous areas several years ago...

    what i ended up doing was to attach my chosen timeslice method to an interrupt vector (F1 in my case) and then i just called that interrupt when i needed or wanted to... this let the system chain in the proper timeslice routine based on
    the OS and i just called the same interrupt no matter what routine was in it...

    my setup uses one of five slicers, depending on the OS... one for OS/2 Warp3, one for OS/2 Warp4, all other OS/2 and Windows use DPMI slicing... then there DESQview slicing and finally the old INT28 DOS slicing...

    FWIW: the only difference between my Warp3 and Warp4 slicing is the Warp3 stuff
    is set to sleep for 2ms whereas the Warp4 stuff is set to 0 (meaning "sleep now!")...

    as for when i call my slicing/sleeping stuff, that depends on my program and what its doing at the time... if i'm doing a lot of disk processing, i might sleep every 50 records processed or every 100 lines read... if its pretty much memory intensive, i may sleep after each second... it really depends... one of my applications uses both time based and processing based slicing calls... during intensive disk processing, it uses record based slicing and no timer based... the reason for this is to keep the effective processing speed of the program relatively bearable... if i sliced on each record or line read during file processing, it may take a long long time for the program to finish what it
    is doing but it would be very very very multitasker friendly... on the other hand, if i slice away only once per 1000 records processed, the application would do the disk processing very fast but be very multitasker unfriendly...

    i don't know that i can show the entire code setup that i use because there is some inline asm as well as numerous asm routines mixed in with the pascal... i can possibly post the actual slicing calls if desired... i had to play with them and work some things out for myself... some of my experimenting did cause lockups and lost data...

    )\/(ark


    * Origin: (1:3634/12)
  • From mark lewis@1:3634/12 to Jasen Betts on Sunday, December 14, 2003 20:53:14
    For A := 0 to 100 do
    begin
    {Do some stuff here}
    TimeSlice;
    end;

    It would do 100 timeslices back to back.

    first off check the documentation for "timeslice" I don't
    find it documented as a standard part of TP

    it is most likely a custom procedure... i call mine "killtime"...

    What I'm guessing it does is inform a multitasker that the
    program is not busy so that the multitasker can dedicate
    more cpu effort to running other tasks. (AFAIK windows
    OS/2 and Dessqview all do that in slightly different ways
    (if you're using a dos compiler)

    all true... in my previous message, i noted 5 seperate slicers that i use... of
    those, there are 4 distinctly seperate ones...

    I have read that you should time them to be at least 55 ms
    apart ( depending on the system ). That if you do like I
    did above it will accually make the application use more
    of the CPU.

    I don't see how it could cause more CPU usage than putting
    some form of delay loop between calls to timeslice.

    me either... and to do that properly would mean chaining the timer interrupt and counting... that's not that hard to do, though... i have stuff here that i use in some debugging and routine timing stuff that sets the clock timer interrupt to fire off 1000 times a second instead of the default 18.2 times a second... yeah, one has to make sure that they call the original clock vector every 18.2 times a second or the system clock will run ahead quite quickly...

    Maybe someone could explain to me all about Time Slices. Or
    point me in the direction of a place I can read up on them.

    OTOH if you want to delay for a long time there may be some
    sort of sleep procedure avaialable. (but your code suggests
    to me that you want to "do some stuff" between timeslices so
    probably you are doing it the best way.

    yes, to me, it, too, appears that he is wanting to make his stuff more multitasker friendly...

    )\/(ark


    * Origin: (1:3634/12)
  • From Chris Hoppman@1:129/305 to Mark Lewis on Monday, December 15, 2003 11:35:37
    For A := 0 to 100 do
    begin
    {Do some stuff here}
    TimeSlice;
    end;
    It would do 100 timeslices back to back.

    as for when i call my slicing/sleeping stuff, that depends on my program an what its doing at the time... if i'm doing a lot of disk processing, i migh sleep every 50 records processed or every 100 lines read... if its pretty m memory intensive, i may sleep after each second... it really depends... one my applications uses both time based and processing based slicing calls... during intensive disk processing, it uses record based slicing and no timer based... the reason for this is to keep the effective processing speed of t program relatively bearable... if i sliced on each record or line read duri file processing, it may take a long long time for the program to finish wha it is doing but it would be very very very multitasker friendly... on the other hand, if i slice away only once per 1000 records processed, the application would do the disk processing very fast but be very multitasker unfriendly...

    This is stuff I can use, cause what I was doing was had it release a slice not in a wait procedure, but in times it is getting input and you said it would freeze the program and take a long time to complete. This is helpful. Cause if it is running a task. I should wait a while, before giving up a timeslice, but when it is just waitting for input I should give up a timeslice each time. (tell it to sleep).., because it is sorta not processing anything until input is givin'.

    what operating system, version and timeslice style?? all three are needed t be known... there are several ways of timeslicing... choosing the proper on depends on the operating system and in some cases, which version of the operating system...

    Basicly you gave me the ones that I have already. (not the code, but
    told me the ones). OS/2-Desqview-Windows(real mode)-DOS. All versions
    :)~. I need to know about Win2k though..

    FWIW: the only difference between my Warp3 and Warp4 slicing is the Warp3 stuff is set to sleep for 2ms whereas the Warp4 stuff is set to 0 (meaning "sleep now!")...

    ?..
    Do you mean that a timeslice pauses your program or ie sleep. I sorta understand this part, but just wantted to make sure.

    i don't know that i can show the entire code setup that i use because there some inline asm as well as numerous asm routines mixed in with the pascal.. can possibly post the actual slicing calls if desired... i had to play with them and work some things out for myself... some of my experimenting did ca lockups and lost data...

    That is alright I already have code your talking about, but just wantted to understand the way it works better and find out proper ways of using it.
    You have taught me a few things.


    1: TimeSlices pauses your program and lets other process to run.
    or also called sleep.

    2: So, it is best to do a timeslice when your program isn't doing
    heavy processing. If you do a timeslice in this processing
    don't do it back to back, let the program run for a while
    before giving one up or it will take a long time to finish
    what it is doing. On the other hand if you don't give one
    after a certain time the OS will suffer from lack of (for
    lack of words) cpu time.

    3: Try to give up timeslices when your program is idle, like
    waitting for input. Then process that input and while
    processing that input see #2.

    4: It do mader when and where a timeslice is in the code. See
    #1, #2, #3.

    ;)
    chris

    --- Renegade v11-26.3 DOS
    * Origin: The Titantic BBS Telnet - ttb.slyip.com (1:129/305)
  • From Chris Hoppman@1:129/305 to Mark Lewis on Monday, December 15, 2003 11:39:25
    yes, to me, it, too, appears that he is wanting to make his stuff more multitasker friendly...

    yep.. The problem isn't when one person is on the board , but while two people are logged on and then the cpu usage goes up and the board is jumpy, but see why it might be in the pervious post. I am doing the timeslices in the wrong places. While it is processing information. Instead of letting it proces
    and then after a few minutes (or after it process's a set amount of stuff) give up a timeslice.

    chris

    --- Renegade v11-26.3 DOS
    * Origin: The Titantic BBS Telnet - ttb.slyip.com (1:129/305)
  • From mark lewis@1:3634/12 to Chris Hoppman on Monday, December 15, 2003 17:16:02
    [trim]

    it is doing but it would be very very very multitasker
    friendly... on the other hand, if i slice away only
    once per 1000 records processed, the application would
    do the disk processing very fast but be very
    multitasker unfriendly...

    This is stuff I can use, cause what I was doing was had
    it release a slice not in a wait procedure, but in
    times it is getting input and you said it would freeze
    the program and take a long time to complete. This is
    helpful. Cause if it is running a task. I should wait
    a while, before giving up a timeslice, but when it is
    just waitting for input I should give up a timeslice
    each time. (tell it to sleep).., because it is sorta not
    processing anything until input is givin'.

    yes, pretty much... glad i was able to confirm for you...

    what operating system, version and timeslice style?? all
    three are needed to be known... there are several ways of
    timeslicing... choosing the proper one depends on the
    operating system and in some cases, which version of the
    operating system...

    Basicly you gave me the ones that I have already. (not the
    code, but told me the ones). OS/2-Desqview-Windows(real mode)-DOS.
    All versions :)~.

    ok... as i understand it TOPView also uses the DESQview slice call...

    I need to know about Win2k though..

    AFAIK, i just use the same windows slice... i'm not aware of any other...

    FWIW: the only difference between my Warp3 and Warp4 slicing
    is the Warp3 stuff is set to sleep for 2ms whereas the Warp4
    stuff is set to 0 (meaning "sleep now!")...

    ?..
    Do you mean that a timeslice pauses your program or ie sleep.
    I sorta understand this part, but just wantted to make sure.

    ummm... the 2 tells that routine to sleep for 2ms... 0 means sleep now and give
    up /this/ slice... i forget why i ended up doing it that way but it had to do with some change that IBM had put in Warp4... it may have changed in later fixpacks for Warp4 but i've not updated and tested... since i've also had no complaints, i can only assume that things are working as desired...

    i don't know that i can show the entire code setup that i
    use because there some inline asm as well as numerous asm
    routines mixed in with the pascal.. can possibly post the
    actual slicing calls if desired... i had to play with them
    and work some things out for myself... some of my
    experimenting did cause lockups and lost data...

    That is alright I already have code your talking about, but
    just wantted to understand the way it works better and find
    out proper ways of using it.

    you may very well have the stuff i have... i dunno... i've /lots/ of it... some
    is similar, some is identicle and some is different... i just took what i thought was the better and what i was able to understand and pieced it together
    in my own way...

    You have taught me a few things.

    excellent!

    1: TimeSlices pauses your program and lets other process to
    run. or also called sleep.

    in so many words, yes, that's probably as accurate as we can get it...

    2: So, it is best to do a timeslice when your program isn't
    doing
    heavy processing. If you do a timeslice in this processing
    don't do it back to back, let the program run for a while
    before giving one up or it will take a long time to finish
    what it is doing. On the other hand if you don't give one
    after a certain time the OS will suffer from lack of (for
    lack of words) cpu time.

    right... if you slice while reading records, only slice after reading X number of records... also note that this is not a fixed number, either... some tuning is necessary...

    3: Try to give up timeslices when your program is idle, like
    waitting for input. Then process that input and while
    processing that input see #2.

    right...

    4: It do mader when and where a timeslice is in the code. See
    #1, #2, #3.

    not that i'm aware of... i just added slicing to one of my languishing projects
    and let it slice at the top of each loop thru the reading of the records and processing of the datafiles... its simple counter program that gathers record sizes from several datafiles for each record in the master datafile... if the secondary files exist, i slice before reading and processing them... if they do
    not exist, i don't slice... this gives me the fastest traversal thru the master
    datafile and then decent speed while processing the secondary datafiles... i've
    got a distributed computing project running on my system so it hovers about 50%
    utilization all the time... this project of mine only taps it up a few percent... i guess i should stop that background process and let my cpu usage drop to 0% and then test my routines to see how badly they really do impact the
    system...

    )\/(ark


    * Origin: (1:3634/12)
  • From Scott Adams@1:112/91 to Chris Hoppman on Friday, December 12, 2003 07:10:15
    Quoting Chris Hoppman to All <=-

    Since ya'll are asking for someone to help. Maybe you can help me
    with a problem I am having with a source code I am modifing.

    It has timeslices built into it, but the CPU usage is still in the
    upper limits (89-98%). I sorta remember something I have read and wantted to verify it. That the timeslices shouldn't be gave at
    anytime. Like say you do this.
    For A := 0 to 100 do
    begin
    {Do some stuff here}
    TimeSlice;
    end;

    It would do 100 timeslices back to back.

    I have read that you should time them to be at least 55 ms apart
    ( depending on the system ). That if you do like I did above it will accually make the application use more of the CPU.

    Maybe someone could explain to me all about Time Slices. Or point me
    in the direction of a place I can read up on them.

    I actually never sat down to use timeslices except for a few
    Java programs. The only close to that would be simple
    program/execution delays. With that said my experience with
    such is just not as high say as some.

    The problem is that with today's modern compilers and computers
    getting faster and faster every day timeslices get less
    and less value. A timeslice for a old 286 is just nothing
    for a 5 gigmhz machine. So you have to adapt your timeslices
    for the actual cpu speed. So if you really really want
    to get involved you should get code to detect the cpu speed
    and then modify the timeslice accordingly.

    Another thing is why do you need the timeslice? A multi-tasking
    software? A TSR? A game? The particular type of software
    also indicates how to go. A game sometimes need fast and
    sometimes slow timeslices, for example.

    Now with that stuff said have you checked out SWAG? It has
    at least 3 sample codes using the keyword time slice in it.
    One for os/2 and Desqview and 2 others general code sources.
    Keep in mind though those are in pure assembler. But ASM
    is a good way to go with timeslices.

    ... Now, what was that magic word? Shazzam? <WHAM!> Nah - Garibaldi
    --- Fringe BBS
    * Origin: EWOG II - The Fringe - 904-733-1721 (1:112/91)
  • From Chris Hoppman@1:129/305 to Scott Adams on Thursday, December 18, 2003 13:53:49
    Another thing is why do you need the timeslice? A multi-tasking
    software? A TSR? A game? The particular type of software
    also indicates how to go. A game sometimes need fast and
    sometimes slow timeslices, for example.


    16-Bit Real Mode BBS software.

    Now with that stuff said have you checked out SWAG? It has
    at least 3 sample codes using the keyword time slice in it.
    One for os/2 and Desqview and 2 others general code sources.
    Keep in mind though those are in pure assembler. But ASM
    is a good way to go with timeslices.

    Yes, but I don't need to learn how to do them, *except if there is others for Win2k*, I needed to learn the proper ways to execute them. The Where and When.. As, my example program shows.

    chris

    --- Renegade v12-15.3 - Alpha
    * Origin: The Titantic BBS Telnet - ttb.slyip.com (1:129/305)
  • From Scott Adams@1:112/91 to Chris Hoppman on Monday, January 12, 2004 00:16:41
    Quoting Chris Hoppman to Scott Adams <=-

    Another thing is why do you need the timeslice? A multi-tasking
    software? A TSR? A game? The particular type of software
    also indicates how to go. A game sometimes need fast and
    sometimes slow timeslices, for example.


    16-Bit Real Mode BBS software.

    Then likely you'll not need much of a timeslice since real
    modes tend to be exclusive programs. Though with windows
    and dos boxes that's somewhat true today. So its up to
    you if you need it for 16 bit work.

    Now with that stuff said have you checked out SWAG? It has
    at least 3 sample codes using the keyword time slice in it.
    One for os/2 and Desqview and 2 others general code sources.
    Keep in mind though those are in pure assembler. But ASM
    is a good way to go with timeslices.

    Yes, but I don't need to learn how to do them, *except if there is
    others for Win2k*, I needed to learn the proper ways to execute them. The Where and When.. As, my example program shows.

    We'll I'd still look at SWAG it might give you that advice.

    As to where and when its judgemental. Theres no solid rule
    of thumb. It depends on the program.

    If your running a program that takes alot of constant input
    like a game then they are good. If your using a when needed
    input like a spreadsheet then theres not much need for them
    unless you plan to allow shared programs.








    ... "Well, this is it." - Garibaldi
    --- Fringe BBS
    * Origin: EWOG II - The Fringe - 904-733-1721 (1:112/91)