An Efficient Knapsack-Based Approach For Calculating The Worst-Case Demand of Avr Tasks