I have $P$ different processes given along with their respective Burst time and arrival time. The time quantum is $1$ sec i.e. each process can only run for $1$ sec. There's a total time $F$ given for which computer will be available to perform these processes. Also for each process $P_i$ there exists a respective cost/sec for not performing it. There's no penalty for the waiting time. Penalty is on the basis of how much percaentage of burst time was left. Preemption is allowed.
For Eg- If $P=3$,$F=10$. $P_1$ has burst time of $9$ sec and penalty of $10/sec$ for $P_1$ Suppose the Gantt Chart comes out to be $|P_1P_2P_3P_1P_2P_2P_1P_1P_2P_1|$
Since $P_1$ was allowed to run for only $5$ sec till the end of all processes so total penalty will be $(9-5)*10= 40$ .
I have to schedule the process in so as to minimize the sum of penalty for all processes.
If priority was given instead of penalty for no-operation, I would simply select the process first on basis of arrival time and then on the basis of priority and then preempt the process like Preemptive Priority scheduling.
I tried it by using greedy approach. First I sort the jobs on basis of Arrival time and then if clash occurs then on the basis on cost so as to minimize the sum of total cost incurred. I choose the job with min Arrival time and maximum Cost.
Is there any more optimal and efficient way to minimize the total cost ?