home hardware prices news articles forums photos user reviews
Go Back   Tech Support Forums - TechIMO.com > PC Hardware and Tech > Webmastering and Programming
Join TechIMO for Free!
Register Blogs FAQ Members List Calendar Search Today's Posts Mark Forums Read
Reply Get bargains at  »  Dealighted.com
 
Thread Tools
Currently Active Users: 2721
Discussions: 186,607, Posts: 2,227,058, Members: 230,242
Free Scan: Update Your PC's Outdated Drivers to Optimize Performance
Old September 30th, 2008, 01:18 AM   Digg it!   #1 (permalink)
Junior Member
 
Join Date: Sep 2008
Posts: 1
Question
simple memory allocation system

Hey, i would really like some help with this question:

Develop a program which represents a simple memory allocation system.
This sytem processes one integrated memory and the allocating technique.
In this system, process ID will be created by the program but adding or removing
any process to/from the memory is based on the user's entry. each process has a unique
ID and size(the space needed for process in memory).

User's entry should include 3 parts:
1. User will choose to add or remove a process

2. If user chooses to add the next entry is task size. If user chooses
delete the next entry is the process ID to remove

3. If user selects add, then he must choose either the First fit or BestFit method.

package javaapplication1;
import javax.swing.*;
import java.lang.*;

public class Main{
//void memAllo(){

public static void main(String []args){
Main themain = new Main();

int[] memory = new int [56];
int processId = 0;
int taskSize = 0;
int choice = 0, choice2=0;
//User selects task - add or remove process
String A = JOptionPane.showInputDialog(null, "Please enter either 1 or 2 : \n 1- Add Process " +
"\n 2- Remove Process ","CHOOSE", JOptionPane.QUESTION_MESSAGE);
choice = Integer.parseInt(A);

switch(choice){
case 1:// user chooses to add
taskSize = themain.getTaskSize();//getting taskSize from user after user decides to add process
String B = JOptionPane.showInputDialog(null, "Please enter either 1 or 2 : \n 1- First Fit (FF) \n 2- BestFit (BF)",
"CHOOSE", JOptionPane.QUESTION_MESSAGE);
choice2 = Integer.parseInt(B);
switch(choice2){
case 1:
processId++;
themain.writeToMem(taskSize,processId,memory);

case 2:
default: JOptionPane.showMessageDialog(null,"Invalid Choice, Please try again",
"MESSAGE",JOptionPane.INFORMATION_MESSAGE);
}
case 2://user chooses to delete
default: JOptionPane.showMessageDialog(null,"Invalid Choice, Please try again",
"MESSAGE",JOptionPane.INFORMATION_MESSAGE);

}

}
public void writeToMem(int taskSize,int processId, int[]memory){
for(; taskSize > 0; taskSize--){
memory[taskSize-1]=processId ;
}
System.out.print(memory);
}

public int getTaskSize(){

String C = JOptionPane.showInputDialog(null, "Task Size - Integers from 1 to 9",
"CHOOSE", JOptionPane.QUESTION_MESSAGE);
int ts = Integer.parseInt(C);
return ts;
}


}

I've enclosed my code which is how far I've gotten so far, which is not too far,
I have a general understanding of the question but I don't know how to execute cause my
programming skills are limited. Any help would be appreciated.

By the way is C++ better suited for a program of this type or is java ok?

ShawnCie is offline   Reply With Quote
TechIMO.com Ads - Login or register for less ads.
How many errors does your computer have?

You no longer need to guess! This free stability scan and registry cleaner download will give you a complete diagnosis of your Windows registry, identifying errors and conflicts.

FREE instant scan


Guest, Register Free! to remove this ad and get your tech support questions answered in minutes!
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may post new threads
You may post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Game pauses or hiccups! Video Memory or System Memory! Professional Help! DanielMsi Graphics Cards and Displays 9 October 18th, 2005 04:28 PM
Really Simple Memory Question iwishiwasafish Processors, Memory, and Overclocking 2 June 17th, 2005 07:38 AM
IOS Real Mode Memory Allocation Failure rlpos Technical Support 1 March 6th, 2003 12:53 PM
A Simple Question Concerning Memory Stoney80 General Tech Discussion 2 February 12th, 2003 05:53 PM

Most Active Discussions
Is It Just Me? (531)
Misery Loves Company... (1849)
Why Does the MOON Grow Bigger as It.. (18)
heatsink issue (10)
New Mobo (18)
UPGRADING C/D DRIVE TO 250GB & .. (14)
1 internet. 1 house. 3 computer. ho.. (13)
SSD's, RAID, and External Backup (7)
Is This A Compatible Gaming PC? (18)
Recent Discussions
32 or 64 bit vista (4)
Big problem with my PC (2)
system restore 'next' button wo.. (2)
Building my first PC and need s.. (1)
firewall (1)
C++ compiler suggestions (4)
Official World of Warcraft Thre.. (4529)
Programming question (2)
UPGRADING C/D DRIVE TO 250GB &a.. (14)
FS: Dell 6000 laptop, modded 36.. (2)
Apple iPod touch 16 GB $200 (4)
Six 28-Disc Cross Design Black .. (4)


All times are GMT -4. The time now is 12:20 PM.
TechIMO Copyright 2008 All Enthusiast, Inc.



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28