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

  • Home
  • SEARCH
  • 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 9014965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:38:05+00:00 2026-06-16T03:38:05+00:00

I have the following code: struct cache_t * /* pointer to cache created */

  • 0

I have the following code:

struct cache_t *                /* pointer to cache created */
cache_create(char *name,        /* name of the cache */
             int nsets,         /* total number of sets in cache */
             int bsize,         /* block (line) size of cache */
             int balloc,        /* allocate data space for blocks? */
             int usize,         /* size of user data to alloc w/blks */
             int assoc,         /* associativity of cache */
             enum cache_policy policy,  /* replacement policy w/in sets */
             /* block access function, see description w/in struct cache def */
             unsigned int (*blk_access_fn) (enum mem_cmd cmd,
                                            md_addr_t baddr, int bsize,
                                            struct cache_blk_t * blk,
                                            tick_t now,
                                            int context_id),
             unsigned int hit_latency)
{                               /* latency in cycles for a hit */
    struct cache_t *cp;
    struct cache_blk_t *blk;
    int i, j, bindex;
----
----
---

  cp->blk_access_fn = blk_access_fn;

----
---

I WANT TO PRINT context_id and baddr . HOW CAN I DO IT ?
I have tried typecasting and everything but it keeps giving me error:
symbol “context_id” is invalid in current context.
HELP WOULD BE APPRECIATED.

  • 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-16T03:38:06+00:00Added an answer on June 16, 2026 at 3:38 am

    I think you misunderstand the cache_create function. It doesn’t have context_id or baddr parameters at all. What it does have as a parameter is blk_access_fn which is a function pointer. That function which is presumably called by cache_create and it would have those 2 variables as parameters.

    A way to better visualize this would be like so:

    typedef unsigned int (*blk_access_fn_ptr)(enum mem_cmd cmd, md_addr_t baddr, int bsize, struct cache_blk_t *blk, tick_t now, int context_id);
    
    struct cache_t *            /* pointer to cache created */
    cache_create(char *name,        /* name of the cache */
         int nsets,         /* total number of sets in cache */
         int bsize,         /* block (line) size of cache */
         int balloc,        /* allocate data space for blocks? */
         int usize,         /* size of user data to alloc w/blks */
         int assoc,         /* associativity of cache */
         enum cache_policy policy,  /* replacement policy w/in sets */
         /* block access function, see description w/in struct cache def */
         blk_access_fn_ptr blk_access_fn,
         unsigned int hit_latency)  /* latency in cycles for a hit */
    {
        ...
    }
    

    This code is identical in functionality to the code you posted. As you can see, cache_create doesn’t have the parameters you are looking for at all. You must pass a function with an appropriate prototype as the blk_access_fn parameter, and it will have them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code int ParseData(unsigned char *packet, int len) { struct ethhdr
I have the following code: struct VRfile{ char sessionID[10]; char file[20]; int first; };
Suppose I have the following code: typedef struct { char **p; } STRUCT; int
Say I have the following code: struct date { int day; int month; int
I have the following code: class outer { struct inner { int var1; int
I have the following code: #include <boost/shared_ptr.hpp> struct Foo { int a; }; static
I have the following code: template <class T> struct pointer { operator pointer<const T>()
I have the following code struct Node { int accnumber; float balance; Node *next;
I have the following code: typedef struct AdjMatrix { int nodes; int **adjMat; }
Suppose I have the following code: struct Obj { mutable bool valueIsCached_; mutable int

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.