Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9319165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T03:18:54+00:00 2026-06-19T03:18:54+00:00

I have three operations. Each operation is in a loop and has a flag

  • 0

I have three operations. Each operation is in a loop and has a flag value that decreases when the operation is running. While the operation is running, any other operation with the flag value reaching the maximum threshold should interrupt it and run instead (has the highest priority). The flag value changes according to a differential equation against time.

  • I want each operation’s flag value to increase when another operation is running, and signal the system to switch to it when the flag value reaches the maximum threshold.
  • The flag value of each operation increases and decreases according to a specific differential equation that changes with time when the operation is running.

All operations are currently in one file, looped in a Switch case statement. The current code is :

while 1
  [value, index]=max(flag);
  switch index
      case 1
          operation1
          ...
          ...
          flag = [x y z]
      case 2
          operation2
          ...
          ...
          flag = [x y z]
      case 3
          operation3
          ...
          ...
          flag = [x y z]
    end
end

Any ideas ? If you need me to explain a bit better then please do tell me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T03:18:55+00:00Added an answer on June 19, 2026 at 3:18 am

    There are several approaches here

    1. Each time an operation is run, the others should gain some weight, the next time an operation is selected the one with the highest weight is chosen.
    2. Each millisecond an operation is run, the others should gain some weight, the next time an operation is selected the one with the highest weight is chosen.
    3. Each millisecond an operation is run, the others should gain some weight. As soon as an operation loses its highest flag status it should be interrupted.

    Each requires a different solution


    Here are some suggested solutions, for the corresponding problems:

    1. Fairly trivial, just increase the flag of all operations by 1 everytime you run an operation, or alternately reduce the flag of this operation by 1.
    2. Measure the time that it took to complete the operation (perhaps with tic and toc), increase the flag of all other operations with this value.
    3. Give the flag as input to the operation, and inside the operation stop when the elapsed time lets this operation exceed one other flag. Note that without adjustment this means that you basically try to alternate operations by the millisecond.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have three lists with the same number of elements in each other, i
Guys, I have the following code that is inside a big while loop that
I have a WSDL which has multiple operations. For each op i want a
In my application I have a loop that in each turn creates an instance
I have three looped operations O1 O2 O3 each with an IF statement and
I have three nested loop in Matlab and in each loop, I have an
In Matlab, I have a loop that performs operations on arrays. I would like
I a having a little trouble with vector or array operations. I have three
In My application have time consuming process.There fore i try to do that operation
Have three divs in a container that I want to float over a large

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.