Programming :: How To Allocate Region Of Memories Which Similar VirtualAlloc?
May 21, 2011
I was looking for a method of allocating memories on Linux which similar VirtualAlloc on Windows.Requirements are:
1. Size of memories block to allocate is 2^16.
2. Address of memories block is larger than 0x0000ffff
3. Address of memories block must have last 16 bits are zero.
On Windows because lower limit of application address (lpMinimumApplicationAddress) we have (2) obvious right. From (1), (2) and system rules we also achieved (3).
I've been looking on the internet on what filesystem is best suited for flash memories like USB keys, mmc, SD cards and the likes, but I'm not feeling quite satisfied with the answers I got.There are two use cases I'm dealing with:1) I have an SD card that I want to use for storing some data I'm working on. I need to preserve file permissions, and I need to maximize seek and read speed, but the filesystem is accessed for writes quite often too.2) I want to install a linux distribution on a USB keyNow, I've been reading around that said memories are block devices, and that I should stick to regular filesystems. I went for ext2 for the first case, but I experienced data loss on a brand new PNY SD card, which is unacceptable.
Also, I suspect ext2 is striving for writing files consecutively or in some other harddisk-optimized way, which looks like a complete waste to me.In addition, other filesystems would flood the memory with journal crap.I looked into JFFS2, UBIFS, LogFS and here's what I came up with (some statements are contraddictory):- journaling might shorten the memory's life, and it will definitely slow things down- wear leveling is always hardware-implemented, and a software wear leveling could cancel out with the hardware's effort- hardware wear leveling has often a cheap implementation, and a better software wear leveling is desirable- JFFS2 doesn't store any index on the device; this comes at the cost of a slow mount but the flash memory is accessed less often- LogFS should work well on memories up to 64mb- MTD-oriented filesystems can be used on block devices- ext3 = ext2 + journaling- ext3 is not just ext2 with journalingSo, is there anyone who can add someclarification to all this? Should I go ext2 everywhere, or ext4, or should I try one of those MTD filesystems? If so which one? What's the risk/drawback of each solution?
My system has Intel Xeon 4-core cpu(hyperthreading 8-core) and run 64-bit linux. I want to allocate one core for general process(kernel process & other processes). And then, I want to allocate the rest of core for the specific multi-thread program.
Q1: I know that I can pthread_setaffinity() for user-mode thread and mpstat for monitoring. So, how can I allocate a core for kernel process and monitor it?
Q2: How can I restrict use of the cores for the multi-thread program? I don't want kernel process to use the cores for the multi-thread program.
I went to an interview last week and there was this guy who asked a simple question that i have been trying to solve for a couple of days. I tried google but i just cant get the search keywords right. The result were just useless. Well, the question is : "How can we allocate a limited memory to a process before we start its execution" well, the question is related to an X11 system so may be some flags must be set to limit its memory.
I am developing a code where I need to store the planes of an object in a tree & also i need to store it in a list for further processing ... when I try to allocate using malloc the memory allocation when i checked this in internet , I came to know that it may because the memory that I am trying to allocate may be more than the size_t variable.
I am writing a function(in C language in Linux) to initialize an array of a structure from a mysql table by calling a function by reference but I have a problem with call this function by reference . this is my program:PHP Code:
I am building a queue system (in C on CentOS 5) where each directory queue has a number of process instances 'watching' it. I have a root-permission queue supervisor process which does all the forking, and the instance processes give up root as their first action. For max security each queue is accessible to a different set of users and groups.
I need to keep the RAM requirements as low as possible, so I am relying heavily on copy-on-write (since all memory writes are to shmget() shared memory)
Each process presently dlopen's the libraries it requires after fork, but I'm wondering if I would gain by performing the dlopen before forking a number of instances which all require the same libraries.
Any pointers to mid-level tutorials on dlopen and fork internals would be most appreciated: this is about my third post anywhere since I converted to Linux, but I just can't find the answer to this anywhere online.
Is it possible to create a loadable module for a C app that could be loaded into the app in runtime from a CLI or web interface?I would like the code to handle a particular type of structure to be "swappable" for lack of a better term. This would allow different modules to be used based on the users wants without having to mess with code. A different module could be downloaded into the application directory then loaded. Basicaly the code would be handed a pointer process it then return it.
I want to remove duplicate or multiple similar lines from multiple files. I.e. if I have four files file1.txt file2.txt file3.txt and file4.txt and would like to find and remove similar lines from all these files keeping only one line from these similar lines. I only that uniq can be used to remove similar lines from a sorted file.
Is there a perl module that will let me turn numbers into human readable measures of time? For example, 1280513294 would be "26 days ago". If so, what's its name?
I am trying to create a shell script similar to ls, but which only lists directories. I have the first half working (no argument version), but trying to make it accept an argument, I am failing. My logic is sound I think, but I'm missing something on the syntax.
Code: if [ $# -eq 0 ] ; then d=`pwd` for i in * ; do if test -d $d/$i ; then echo "$i:" code....
That's the message I see briefly right before I am booted into Ubuntu Meerkat. It's right after the boot menu and the boot into Ubuntu begins and the screen is still black when that message appears.
I realized I can watch DVDs on my laptop. I tried the first DVD that I had tried it on, and it didn't work. I am thinking this may be something to do with region codes. First of all, how do I see which region code I am currently on? Secondly, how do I reset the region code? Is there any way to use multiple region codes at once?
I have many DVDs that I purchased in Europe (Region 2) and I would like to copy them and change the region for easier reading here in North America (Region 1). In an ideal world, region 0 would be even better.k9copy works fine as far as copying, but the region is kept. I haven't found any setting in k9copy to change the region - is there one? If not, any other application that can do it?
I have this 17" Dell laptop, and the touchpad is huge. My family use it and when we're typing, we brush of this incredibly large touchpad and end up pumping characters into the middle of a prior paragraph.
They've reduced the size of the touchpad on the newer versions of this model, but I'm wondering is it possible to hack it somehow so the outer perimeter (say 1cm) is 'dead'?
Most configuration software available is of no use to me since I think it's not a synaptics mouse. (I don't have multitouch - that's why I think this)
This is really frustrating. Does anyone know how I can do this?
Is there a way to get DVD region code from command line (linux/ubuntu 9.10)? I want to script this action and store the region code (and other data about DVD) in a log.
I am looking for the info about media, not the drive.
My laptop is having issues with DVD's. I can play region free DVD's (they were gifts), but I can't play any of my legit Region 1 DVD's? I downloaded the codecs from the software center but for whatever reason, They don't work, both Mplayer and Movie player just give me error messages when I load the disks. I know the disks are being read, their name pops up and everything, but I guess it just cant read the files.
I know I can use things like regionset and VLC to bypass region encoding (which I already do), I was really wondering if you can actually purchase a drive that is "region free" without having to apply hacks/ patches/ voodoo etc.I've done the "google thing" and all I come up with is hacks while using windows, I'd really like to get a drive that is completely region free.
i have a debian 5 vps system.. it reports the time as beeing one hour behind, i have tried to change this by setting the time to GMT+1 and setting the time to my local region (Europe-Brittian) using the tzselect command but none get the time to the correct time, one hour ahead of the current time.
When I deleted uninstalling and installing some packages in Yast2 I got this output:
Deleting mc Additional rpm output: rpmdb: PANIC: Invalid argument rpmdb: PANIC: fatal region error detected; run recovery error: db4 error(-30977) from dbcursor->c_put: DB_RUNRECOVERY: Fatal error, run database recovery error: error(-30977) storing record "4.0-1" into Requireversion rpmdb: PANIC: fatal region error detected; run recovery error: db4 error(-30977) from dbcursor->c_get: DB_RUNRECOVERY: Fatal error, run database recovery error: error(-30977) setting "3.0.4-1" records from Requireversion index rpmdb: PANIC: fatal region error detected; run recovery error: db4 error(-30977) from dbcursor->c_get: DB_RUNRECOVERY: Fatal error, run database recovery error: error(-30977) setting "" records from Requireversion index and on and on for 3 pages for every package.
When using Docky and clicking the window minimize button the windows will randomly minimize to the cursor and not to the dock icon. Pressing the dock icon will work as expected. I have read through the Docky bug reports and it seems it has something to do with Docky and compiz losing the window minimize region.
I'm using Mac as a main machine and Ubuntu Netbook as a secondary. Although synergy gives me a good control over Netbook when it works without external monitor, but when I activate VGA monitor, I can only move around the limited region (details are below).
Phenomenon: Cursor can move in the external monitor's screen. No way to move cursor into the netbook's screen via synergy (it's possible from local touchpad/mouse) In the external monitor's screen, curosor moves only within limited region, which I'm guessing is as large as the size of netbook's screen.
Configuration: Use dual screens (uncheck "Same image in all monitors" in the tool "Monitor" on Ubuntu)
I have some problems with CentOS 5.4 and standard kernel 2.6.32.7, which I need for realtime extensions.With the solution in this thread: [URL] I could boot the new standard kernel , There are still two error messages during the boot process: